5

Help with the For loop shell script

view full story
linux-howto

http://www.unix.com – Hi, I have multiple files in a directory. Each file will have a header.I have to check if any of the files has 0 rows other than the header then I have to delete the files. Here “ Empty file” in my case means a file has header information but no data. I have to delete such files. If the file count =1 then delete the files else cp the files from one location to another. #!/bin/bash cd filepath rc=`awk '{n++} END {print n}' file1.csv` if [ $rc -ne 1 ]; then `cp /file1.csv file1path/file2.csv` exit $rc else `rm -rf file1.csv` fi The above script is good for checking one file bu (HowTos)