I would like to know the bit explanation of the piece of below command ...
Please explain below cmd in mv command..
${f} is the same that $f, the variable, right?
There are two parts in shell expansion ${f%.*}, the `%' and the glob pattern `.*' (this is not a regular expression), in this case a dot followed by anything.
The `%' says remove starting from the end of the string as minimum as possible of that which matches the pattern.
If there were two `%%' it would be as much as it is able to match the pattern, starting at the utmost right of the string.
An example: mv -v "$f" "${f%.*}.bak" expands to mv --verbose krsnadasa.original krsnadasa.bak
I would like to replace multiple underscores with hyphens but I have 26,000 files to rename. They are all in one file structure and multiple sub-directories.
It would be much simpler if I had a script to do it. Here are some samples of the file names:
Example 1... (3 Replies)
hi
I have files named
123_234_aaa.jpg
234_231_345.jpg
and i wish to rename these files to
aaa.jpg and 345.jpg. i.e inital number,_,next number should be removed form the file name. Please let me know how can i do it. (2 Replies)
I need help finding a file through terminal and then renaming it automatically.
Here is what I have so far to find the file:
cd /User/Applications
find . */SourceM.app/banner.png | while read line; do mv "$line" banner-.png; done
I want the script to rename the file "banner.png" to... (6 Replies)
Hello,
I have one directory with 3 level sub-directories, and about houndard files under those directories. I need a shell script to rename all patern mateched directories and files.
For example: the patern is AA in the directory or file name.
Orignal directory:... (2 Replies)
I have this directory tree under /apps/myapp/data:
imageshack.us/photo/my-images/703/foldersc.png
How to recursively rename ONLY directories with 5 digits (00000, 00100, 00200,..., 00007, 00107,...)?
I want to add to their name two more zeros:
Before: 00107
After: 0000107
Thanks in... (2 Replies)
I want to find a file say IIFT and check its size is zero or not. If its zero then I have to rename anothe file say WWFT , which is in another folder to WWFT$Todaysdate.
I tried below command:
cd dir2 (*File WWFT is in dir2)
find dir/ -type f -name 'IIFT*' -size 0 -exec mv WWFT... (3 Replies)
Hi,
Need your help in this.
I have an input file that has multiple enrollment_number, somewhat like
1234567
8901234
9856321
6732187
7623465
Now i have to search and delete these enrollment_number recursively from all the files that are within multiple sub-directories of a... (10 Replies)
hi,
Need your help.
I need to write a script for below..
i have two files in directory /home/abc as below:
Watch_20140203_abc.dat
Watchnow_20140203_abc.dat
I have to copy this file from
/home/abc to /home01/home02
after that i have to rename the date part in above two files... (1 Reply)
Hi,
How can I use find command to search string/pattern in a file recursively?
What I tried:
find . -type f -exec cat {} | grep "make" \;
Output:
grep: find: ;: No such file or directory
missing argument to `-exec'
And this:
find . -type f -exec cat {} \; -exec grep "make" {} \;... (12 Replies)
Hello,
I supposed that it was working fine but now I see that it's not working as expected.
I am running under ubuntu14.04, trusty.
My plan was to search folderA and all subdirectories and move any txt file to destination folder, folderB :
find /home/user/folderA/ -type f -iname "*.txt"... (0 Replies)