Showing posts with label Move. Show all posts
Showing posts with label Move. Show all posts

Wednesday, March 30, 2011

Copy / Move

concatenate files together in new filecat oldfile1.ext oldfile2.ext > bothfiles.ext
copy a file and prompt before overwritingcp -i existingfile newfile
copy top # lines of a file to a new filehead -# filename > newfilename
move a file and prompt before overwritingmv -i existingfile newfile

Thursday, March 11, 2010

Does a File Exist?

for EXTENSION in txt TXT csv CSV xls XLS            # For each one in this list,
do                                                  # do the following:
  echo $EXTENSION                                   # Display the extension.
  if [ -e *.$EXTENSION ];                           # if a file exists like that...
     then ls *.$EXTENSION |wc -l                    # then display the count
          mv *.$EXTENSION /dfact/fchecks/out_backup # move file to the backup dir
     else echo '    -- not found'                   # otherwise, display 'not found'   
  fi
done