![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sorting : | satyam_sat | Shell Programming and Scripting | 3 | 04-15-2008 01:30 PM |
| Sorting in C++.. | ronix007 | High Level Programming | 6 | 03-06-2008 05:16 PM |
| regarding file sorting | phani_sree | High Level Programming | 1 | 02-02-2007 03:04 PM |
| sorting in awk | mahabunta | Shell Programming and Scripting | 3 | 01-31-2007 01:56 AM |
| awk sorting | Jaken | Shell Programming and Scripting | 4 | 05-21-2006 10:54 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
I have not tested this...
See this if it works for you ################################################ #!/usr/bin/ksh MP3DIR="where your mp3 resides" ls -1 $MP3 > tmpfile awk -F"-" '{ print $1 }' tmpfile > tmpfile1 uniq tmpfile1 > tmpfile2 while read LINE do count=`find $MP3DIR -name "*$LINE*" -print | wc -l` if [ $count -gt 1 ]; then mkdir $MP3DIR/$LINE > /dev/null mv $LINE* $MP3DIR/$LINE fi done < tmpfile2 rm -f tmpfile* ################################################ |
|
|||||
|
Yep!
Thanx it seems to work!
I tested the first part (ie before the while loop), and that worked. I didn't think of using tmp files, i tried to awk with the same options, working directly on the output of a ls -1: ls -1 *.mp3 | awk -F"-" '{print $1}' as artists names. Any ideas why that won't work? |
|
|||||
|
I dont see any reaon why this should not work.
See the sample run. arfwsp04% ls -ltr total 32 drwxr-xr-x 2 arbor arboradm 96 Apr 27 02:50 atr drwxr-xr-x 3 arbor arboradm 96 Apr 27 07:21 atr_prod -rw-r--r-- 1 arbor arboradm 149 May 11 00:23 data -rw-r--r-- 1 arbor arboradm 5656 May 12 03:05 da_report drwxr-xr-x 4 arbor arboradm 4096 May 13 01:25 final drwxr-xr-x 2 arbor arboradm 96 May 13 01:33 tt -rw-r--r-- 1 arbor arboradm 0 May 13 03:09 a-1.x -rw-r--r-- 1 arbor arboradm 0 May 13 03:09 a-2.x -rw-r--r-- 1 arbor arboradm 0 May 13 03:09 a-3.x -rw-r--r-- 1 arbor arboradm 0 May 13 03:19 b1-1.x -rw-r--r-- 1 arbor arboradm 0 May 13 03:19 b1-2.x arfwsp04% ls -1 | awk -F"-" '{print $1}' a a a atr atr_prod b1 b1 da_report data final tt You say...you can do away with tempfiles...I will like to know..how will u do that.. Thanks Rishi |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|