Little bit help here
i wanna cp the no of files listed in text file...

i tried to use

for songs in $(cat "~Desktop/1/list.txt"); do cp $songs NewSongs/; done

but my text file has the path with spaces like

/home/rhohit/Music/00 Database/Albatroos/Albatroos/Albatroos - 01.आवाज.mp3
/home/rhohit/Music/00 Database/Albatroos/Albatroos/Albatroos - 02.खसेका तारा.mp3
/home/rhohit/Music/00 Database/Albatroos/Albatroos/Albatroos - 05.फर्कि फर्कि.mp3
/home/rhohit/Music/00 Database/Axix/Black & White/Axix - 01.शहिदको सपना.mp3
/home/rhohit/Music/00 Database/Axix/Black & White/Axix - 01.अधुरो प्रेम.mp3
/home/rhohit/Music/00 Database/Axix/Black & White/Axix - 06.बुध्दको शान्ति.mp3

i tried tesing usig echo... using

for songs in $(cat "Desktop/1/list.txt"); do echo $songs; done

/home/rhohit/Music/00
Database/Albatroos/Albatroos/Albatroos
-
01.आवाज.mp3
/home/rhohit/Music/00
Database/Albatroos/Albatroos/Albatroos
-
....
...
.

problem in it breaking at every spaces...
help please!!!

for songs in $(cat "~Desktop/1/list.txt"); do cp $songs NewSongs/; done

The while loop is more appropriate for it. The for loop will need the $IFS (Internal Field Separator) modified.

while read songs
do
    cp "$songs" NewSongs/
done < ~Desktop/1/list.txt
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.