What does the following program do?
for file in *nii.gz; do for loop
file_stem=`basename $file .nii.gz` mv $file $file_stem.old.nii.gz done |
Quote:
It searches for files which has *.nii.gz (like abcnii.gz, 1a232nii.gz, e.t.c.) or in other words files ending with nii.gz Second Line It searches for text after "/" in file names. Though I think this is not required. For E.g. [root@vikas027 ~]# basename /usr/sbin/lsof lsof Third Line Rename all files to .old.nii.gz For e.g. 1a232.nii.gz 1a232.old.nii.gz |
Quote:
|
I understood the first line
But what is done by: file_stem=`basename $file .nii.gz` could you explain part by part what does file_stem do? what does basename $file .nii.gz do? about this mv $file $file_stem.old.nii.gz should it not rename a file ( for eg: asdf.nii.gz) to asdg_stem.old.nii.gz ? Thank you for the help. |
Quote:
Regarding the basename command, the syntax is Code:
basename NAME [SUFFIX] Let me give you a little advice: you should definitively read some good tutorial about Shell Scripting, since your questions are very basic and they demonstrate you did not even consider to open and read a piece of documentation. Please, believe me: it's worth the effort, since shell scripting can spare a lot of time if used with awareness. This one should be a good starting point: http://www.linuxcommand.org/tlcl.php. Hope this really helps! :) |
Quote:
The new syntax allows easier nesting, cannot be confused with single quotes, and backslashes inside are treated as they normally would outside of the $() (the backtick syntax uses backslashes for nesting). |
Quote:
|
All times are GMT -5. The time now is 12:06 AM. |