LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   AWK: print field to end, and character count? (https://www.linuxquestions.org/questions/linux-newbie-8/awk-print-field-to-end-and-character-count-179078/)

ridertech 05-07-2004 04:22 PM

AWK: print field to end, and character count?
 
I originally kept my iTunes music updated from a Windows machine, but recently moved everything to a network storage device so that all my computers have access to the music. Due to Mac's file naming limitations, I need to fix the files that have a name longer than 34 (or is it 31?) characters.

I got the listing for every .mp3 file using...
ls -al /music/iTunes/iTunes Music/*/* | grep .mp3 > itunes

There are two more steps I'd like to take, but getting stuck... Using that itunes file, I want to output everything from the ninth field to the end. Then, I'd also like to add a character count at the end.

ridertech 05-07-2004 05:07 PM

awk - printing field to end
 
For future reference, here is how to print out from a specific field to the end of the line...

If your input file is like this...
testfile 23#1212 test.report 11/12/01 this is ofcourse my comment

Then...
awk '{print substr($0, index($0,$5)) }' input_file

Will print out...
this is ofcourse my comment

Solution found here...
http://forums1.itrc.hp.com/service/f...hreadId=121473


All times are GMT -5. The time now is 08:27 PM.