Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, I have a number of crash.log files scattered about my system and I would like to run a command to find all the crash.log files on the system and ...
  1. #1
    Just Joined!
    Join Date
    Feb 2011
    Posts
    1

    Find and copy same files to single directory

    Hello,

    I have a number of crash.log files scattered about my system and I would like to run a command to find all the crash.log files on the system and copy them to a single directory; each with a unique filename.

    For example, copy crash.log from ~/directory_1 , ~/directory_2 , ~/directory_3 and so on to ~/crash_logs/crash.log1 , ~/crash_logs/crash.log2 , ~/crash_logs/crash.log3 etc.

    Any help would be greatly appreciated.

    Thanks.

  2. #2
    Just Joined!
    Join Date
    Apr 2010
    Location
    Bangalore, India.
    Posts
    12
    u can try with this script..
    =============================
    #!/bin/sh
    for FILE in `locate *crash_logs*`
    do echo $FILE
    mv $FILE /path/to/directory
    done
    ==============================
    and u maybe want zip the file
    tar cvf targetfile.tar /path/to/directory (create zip file)
    tar tvf targetfile.tar (list all files in zipped filebut it wont unzip)
    tar xvf targetfile.tar (extract files in current directory)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •