[Ilugc] Error in awk script
- From: cyborg4k@xxxxxxxxx (Shakthi Kannan)
- Date: Thu Aug 26 15:37:59 2004
Hi!
My awk code was:
$ awk ' { if ( length($0) > 80 ) { printf $FILENAME,
$NR, "\n"} } ' *.c
/tmp/code
Try this:
#!/bin/bash
#Script: len.sh
#Pass the directory as an argument to script
if [$# -ne 1]; then
echo "Usage: len [directory]"
exit 1
fi
for file in `ls $1`; do
awk 'length($0) > 80 {print FILENAME, NR, $0, "\n"}'
$file
done
I will really encourage you to go through some online
awk tutorials:
An AWK Tutorial:
http://www.vectorsite.net/tsawk.html
AWK Tutorial:
http://stud.wsi.edu.pl/~robert/awk/
Guided tour of awk:
http://www.vectorsite.net/tsawk1.html
Regards,
Shaks
=====
--------------------------------------------------------------------------
Gentoo Linux 1.4 (2.6.5-mm1) / FreeBSD Unix 4.9 - Pentium M 1.40GHz - 512 MB -
40 GB - 14" - 4.5-4.9 lbs - CD-RW/DVD-ROM - Intel PRO/1000 Gigabit Ethernet -
Intel PRO/Wireless Network Connection 802.11b
http://www.geocities.com/shakthimaan
--------------------------------------------------------------------------
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush
Other related posts: