LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 03-03-2010, 04:58 PM   #1
Drigo
Member
 
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:

#!/bin/bash


pwd=SOURCE

#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}";

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




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:

11420_07.nii.gz
11420_16.nii.gz
11420_07R.nii.gz
11420_16R.nii.gz
11420_08.nii.gz
11420_17.nii.gz

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

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


Reply


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
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration