LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-13-2009, 12:13 PM   #16
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102

Quote:
Originally Posted by wakatana View Post
So if i dont need to manipulate IFS how can i do this:

input:

Code:
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 01 - album - track001.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 02 - album - track002.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 03 - album - track003.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 04 - album - track004.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 05 - album - track005.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 06 - album - track006.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 07 - album - track007.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 08 - album - track008.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 09 - album - track009.mp3
desiret output

trackXXX.mp3

i foud this can be done with this but did not work for me

Code:
for jmeno in *.mp3
do
  cp $jmeno /tmp/`echo $i | sed "s/\([0-9]\{2\}\).*/track0\1.mp3/"`
done
is this possible using bash and for loop, i am trying to learn something about bash scripting this is what i am intersted in
You are not taking into account the fact that there are spaces in the paths. Do it this way:

Code:
ls -1 *.mp3 | while read jmeno
do
  cp $jmeno /tmp/`echo $i | sed "s/\([0-9]\{2\}\).*/track0\1.mp3/"`
done
Only addressing the loop construction, not its contents.
 
  


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
help with shell variables/commands grndfl Linux - Newbie 2 07-25-2008 05:06 PM
Advanced Maintenance Mode limited shell Doomhammer AIX 1 06-21-2007 04:17 AM
moving files in shell - advanced trscookie Linux - Software 4 04-25-2007 04:25 PM
Shell variables Milosevic Linux - Newbie 2 12-10-2005 10:32 PM
Shell Variables. ducka Programming 5 09-03-2003 05:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:37 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration