Linux rename command but for dynamic values [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have files on a Linux server for example:
2103acc.001.lob
2507acc.002.lob
2222acc.021.lob
1210acc.051.lob
I would like to change them to:
2103acc.pdf
2507acc.pdf
2222acc.pdf
1210acc.pdf
I cannot performo
rename .001.lob .pdf *.lob
because those are dynamics number
Can someone write me the solution?
Thanks

This regexp should remove digits followed by .lob and replace with .pdf:
rename -n -v 's/\.[0-9]+\.lob$/\.pdf/' *.lob
Once you're convinced you have the right pattern, just remove the -n (dry-run) and let it run properly:
rename -v 's/\.[0-9]+\.lob$/\.pdf/' *.lob

Ixer missed a * in his answer, so i added it:
rename -n -v 's/\.[0-9]*\.lob$/\.pdf/' *.lob

Related

Delete file with # in Linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I want to delete a #tem.txt# called # that for some reason using emacs appeared
is between two # and I have not been able to remove it using rm, rm -f, unlink
See my file
Since '#' is a special character, you can try rm \#tem.txt\#

What does command cat /etc/group mean [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I have used a command called 'cat /etc/group' what does this command mean and do.Can you tell me what each part of the command does please use simple terms.
You can find the answer to your question explained better than any of us ever could with this command:
man cat
It prints to standard output the contents of the file at the location /etc/group
Ok so cat outputs the file, which (in your case) contains basic info about groups.
If you are interested in what are the groups just click here

Add a number to the beginning of every-line in a .lst file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
So I used "shuf" to make a word-list, The problem is when I run the command shuf -i 0500000000-0599999999 -o passwords.lst it doesn't type the first number which is '0' so I want a command to type that '0' into the beginning of every-line, if it's not possible with shuf any command will help.
This piped command will simply prepend a zero:
shuf -i 0500000000-0599999999|sed s/^/0/ > passwords.lst

Mass file renaming (Linux) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have a directory in linux with lots of images having double underscore (__), I have to make it single under score (_). Lets say file name is a__1.jpg. I have to make it a_1.jpg. I have to do it for all files inside a directory. What should be the command?
Thanks
There are several ways to achieve this goal.
If you have mmv installed (or are able to install it), you can do
mmv \*__* \#1_#2
If not, maybe rename is an option:
rename _ __ *
(but alas, here I am not so sure about the syntax.)

Delete folders irrespective of whether they are empty or not [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
How to delete folders using single line command irrespective of whether the folder is empty or non-empty?.. Any idea?
The rm(1) command has the flag -r for that. You should not use the -f flag with this command, unless you know what you are doing, as placing a wrong * or space can have you deleting a lot more than you intended.

Resources