Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Search this Thread
Old 03-03-2010, 04:58 PM   #1
Registered: Jun 2009
Posts: 104

Rep: Reputation: 15
Angry showing section in files that have different names...

I am running a bash script and I would like a command that will show me what differs from some files with similar names so I can delete them. Or if you can provide some info on how to complete my script. it will be great>
Here is my code:



#Add extension into the name
for FILE in $( ls $SOURCE*$2*);
do echo $FILE;
if [ $1 = "-rename" ]; then
echo "renaming...."
#mv $FILE "${FILE//$1}";
elif [ $1 = "-replace" ]; then
echo "replacing...."
mv $FILE "${FILE/$2/$3}";

echo "deleting....";
#$2 at the beggining...
#mv $FILE $2_"${FILE//$1}";
# echo "to...." $2_"${FILE//$1}";

This are the filenames under a directory:

11420_07_20090604.nii_Corrected.nii.gz 11420_16_20090914.nii_Corrected.nii.gz
11420_07R_20090604.nii_Corrected.nii.gz 11420_16R_20090914.nii_Corrected.nii.gz
11420_08_20090806.nii_Corrected.nii.gz 11420_17_20090928.nii_Corrected.nii.gz

This is what I want:


I want to get rid of the 2009XXX names that differ.
Thanks in advance!
Old 03-03-2010, 05:05 PM   #2
Senior Member
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
man diff


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
vFat Partition on dsl not showing captitals in file names linuxmandrake DamnSmallLinux 1 04-05-2008 04:58 AM
RPM Spec file creation, %files section question davidas Linux - Software 1 09-13-2007 03:26 AM
VI not showing files with color RonnyNussbaum Linux - Software 8 06-26-2006 04:17 AM
etherape not showing names.. derfaust Linux - Software 0 05-20-2004 12:12 AM
SAMBA: display of share names is OK but files names are wrong superandrzej Linux - Software 5 02-02-2004 10:14 AM

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration