Copy files using filenames from text files with shell script or bash script

Discussion in 'Linux Networking' started by altariamx2003, Nov 20, 2006.

  1. How can I do this????

    I have the file "lista.txt", and this file have the next information:
    one.txt
    two.txt
    five.txt
    six.txt
    -------------------
    This files exist in the same directory that "list.txt", I would like to
    copy this files to other directory

    Using Windows the batch file would be like this: for /f "tokens=*" %i
    in (list.txt) do copy "%i" destdir\

    How can I do something like that in REDHAT??

    Best Regards
     
    altariamx2003, Nov 20, 2006
    #1
    1. Advertisements

  2. altariamx2003

    David M Guest

    David M, Nov 20, 2006
    #2
    1. Advertisements

  3. altariamx2003

    C.J. Steele Guest

    for f in `cat lisa.txt`; do cp $f /dst/dir; done

    -C
     
    C.J. Steele, Nov 20, 2006
    #3
  4. altariamx2003

    Jiri Slaby Guest

    Not a good way if you have filenames with whitespaces in lista.txt.
     
    Jiri Slaby, Nov 20, 2006
    #4
  5. Jiri Slaby kirjoitti:
    How about
    # while read f ; do cp "$f" "/dst/dir" ; done < list.txt
     
    Jarmo Pussinen, Nov 23, 2006
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.