Hi Experts,
I need to list the files in a directory which have more than one lines
All the files are csv format
Please help
Thanks
Hi Experts,
I need to list the files in a directory which have more than one lines
All the files are csv format
Please help
Thanks
You can use the following script.
for file in `find -maxdepth 1 -type f`
do
if [[ `wc -l $file|cut -d ' ' -f 1 ` -gt 1 ]]
then
echo $file
fi
done
for file in *
do
awk 'END{if(NR>1)print FILENAME}' $file
done
cheers,
Devaraj Takhellambam
for files in `find . -maxdepth 1 -type f`
do
if [ "$(grep -c "\n" $files)" -ge 1 ]
then
echo $files
fi
done
You can use the above code also for getting the files which are all having the number of lines more than one
for file in *
do
awk 'NR>1{print FILENAME;exit}' $file
done
With awk (reads the whole file, could be slower with large files):
awk 'NR>1{print FILENAME}' *
Or with gawk (should be the fastest with large files):
gawk 'NR>1{print FILENAME;nextfile}' *
thanks franklin