But now i don't know how to create a loop to copy the wav files from the list to the image directory
i'm missing the command to find the same wav file in the dir from the "match" list (created by
) and then copy to images on to have mirrored png/wav files
Assuming generated your list with grep -vf listA.lst listB.lst or something similar, you can then:-
The -p flag on the cp will preserve the ownership and timestamp of the file, if that is important to you. You would need to run this as root to be able to do that, unless the id running the script already owns the files.
The | while read file_ref sets up the loop and sets the value of file_ref to each string returned from the grep in tuen, so you can work down the list.
Does that help?
I might have the logic the wrong way round, so you might need to sort out the order of the list files, the grep with or without the -v flag and the source directory and extension for the file being copied. To test it first, put an echo before the cp command, so it looks like this:-
If I've got it horribly wrong, please post the error messages so I can have another think.
Kind regards,
Robin
Last edited by rbatte1; 09-16-2015 at 12:21 PM..
Reason: Stronger warning about checking the logic.
Excellent. I'm glad it helped. You might need to be careful if you have a loop within a loop, but if you get stuck, let us know and we can try to help again.
Quote:
for a noob like me
We all had to start somewhere. You should see some of my early stuff! It's truly horrible, but as it works, there is no point replacing it. Until you know the tricks and options to do things, then you might feel a little lost.
Feel free to ask for more help. It works best if you can explain the overall objective, then have a go & show us how far you have got with code, files and input/output & errors so we can help you grow your skills and then be able to write and support your own code.
Hello all!
I want to move several files foo.aux foo.log foo.pdf foo.tex to bar_foo.aux bar_foo.pdf bar_foo.tex
I am on tcsh
% mv foo.* bar_!#:1
is not working.
Thank you for your help
marek (11 Replies)
Hi !
I wonder if anyone can help on this : I have a directory: /xyz that has the following files:
chsLog.107.20130603.gz
chsLog.115.20130603
chsLog.111.20130603.gz
chsLog.107.20130603
chsLog.115.20130603.gz
As you ca see there are two files that are the same but only with a minor... (10 Replies)
Hi all, I am trying to make a for loop invoking files with different extensions (*.ugrd and *.vgrd) and I cant just make it work. Cant figure out how to load the files so as to use them in subsequent commands like the ones in this pseudo code. the files are arranged such that in one date for... (8 Replies)
Hi,
Could someone give me a hand with a search for files with two possible extensions, please. The requirement is simple - I need to issue a single ls command searching for files with the suffix of, say, *.txt and *.log.
I've tried to use ls *.txt *.log which works if there are both... (4 Replies)
Hello !
i have a few files like ...
setup.001
setup.002
setup.003
setup.004
// to
setup.095
and i would like to rename those files to ...
setup.r01
setup.r02
setup.r03
setup.r04
// to
setup.r95 (7 Replies)
I copied some files to another folder, and I want to change them from .doc extensions to .txt extensions. I tried using the cp and mv commands, but it didn't work. Is it possible to change file extensions with these commands, and if so how do I do it? I tried using the * wildcard (say cp *.doc... (1 Reply)
I am trying to write a Korne Shell Script wherein we have to sort
files according to their extensions(for eg. 1.sh, 5.sh, 9.sh together;
4.csh, 120.csh, 6.csh together and 7.ksh, 2.ksh, 59.ksh together) and
move them to their respective directories viz. sh, csh and ksh...
I think,... (1 Reply)
Hi all,
From one directory I need to fetch only files of type *.xls,*.csv,*.txt. I tried the find . -name '*.txt,*.csv,*.xls' -print. But it throws me error. Please do help me on this.
Thanks
Mahalakshmi.A (11 Replies)
I have a unix directory with 500 plus files . When I do a ls -lR I can see ALL the files here . How can I sort this by the files extensions ?
I can't enter ls -lR *.ext1 *.ext2 *.ext3 etc in case I miss out some files . (2 Replies)
I want to select files which have different extensions such as .cpp, .cs, .h
I can select one of them as
find . -name "*.cpp"
but I want to select all of them in one command only. It should be pretty simple but I'm not able to get it. Any help with the command will be greatly appreciated. (1 Reply)