Hello all,
I am a new ubuntu user (have to use it for work) and I am trying to learn and familiarize myself with commands that I will be using frequently.
I would like some help in how I can get a list of all files with certain keywords in the filename.
For example, I have a directory with numerous subdirectories that have a bunch of files in them. Two of those files contain the following format in the name:
numericals_eddy_corrected.nii.gz and
numericals_eddy_corrected_brain_mask.nii.gz.
I want to get a list of all the
eddy_corrected.nii.gz and
eddy_corrected_brain_mask.nii.gz files.
I am wondering, what command do I type in terminal so that I get a list, including the path, of all the files that have
eddy_corrected in the name without the other
eddy_corrected_brain_mask' showing up as well and vice versa? Is there a way to have terminal make a
.txt file of the list?
Second thing I need help with is renaming some files in those subdirectories. These files end in the extension
.bvec and
.bval and have absurdly long names with numbers in the format of
subjectnumberDTISiementsTClessnumericals.bvec/.bval or
1000047785DTISiemensTCless005.bvec etc.
How can I rename all the files in the subdirectories to something simpler or shorter like
subjectnumber_DTI.bvec?
I have heard of
find and
grep but I'm not sure how to go about combining commands to achieve what I need to do.
I will be required to do similar tasks in the future so I figured I should learn it once and for all. I would appreciate any help.
If I have posted this in the wrong forum, please feel free to move it to the correct location.
Thank you in advance.
Moderator's Comments:
|
|
Please use ICODE tags, not B tags for partial line sample input, output, and code segments.
|
|