LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-07-2012, 12:36 PM   #1
dotran
LQ Newbie
 
Registered: Apr 2012
Posts: 27
Blog Entries: 2

Rep: Reputation: Disabled
Please help script loop into the /tmp/filename.txt out put with filename and wc.


I have this code work below worked, but I like do loop if put all the filename in the /tmp didn’t work…......someone help please. Thanks

Quote:
#!/bin/ksh
FILENAME1="AASP.C0042.S0920.FUA01.CHG.LOG:AN:SNRPZFUA:OTA_CHANGE_LOG_FUA.txt"
FILENAME2="AASP.C0042.S0920.FUA01.CLIENT.OTA:AN:SNRPZFUA:OTA_MASTER_FUA.txt"
FILENAME3="SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL .FILE1"
FILENAME4="SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL .FILE2"
FILENAME5="SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET1.NAT.RO LL"
FILENAME6="SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET2.NAT.RO LL"

cd /staging/mds/mds_repository

echo "Filename: `ls /staging/mds/mds_repository/${FILENAME1} | cut -d: -f4`" >> /staging/SOI/dotran/abc.txt
echo "RowCount: `wc /staging/mds/mds_repository/${FILENAME1} | awk '{print $1}'`" >> /staging/SOI/dotran/abc.txt

echo "Filename: `ls /staging/mds/mds_repository/${FILENAME2} | cut -d: -f4`" >> /staging/SOI/dotran/abc.txt
echo "RowCount: `wc /staging/mds/mds_repository/${FILENAME2} | awk '{print $1}'`" >> /staging/SOI/dotran/abc.txt

echo "Filename: `ls /staging/mds/mds_repository/${FILENAME3} | cut -d: -f4`" >> /staging/SOI/dotran/abc.txt
echo "RowCount: `wc /staging/mds/mds_repository/${FILENAME3} | awk '{print $1}'`" >> /staging/SOI/dotran/abc.txt

echo "Filename: `ls /staging/mds/mds_repository/${FILENAME4} | cut -d: -f4`" >> /staging/SOI/dontran/abc.txt
echo "RowCount: `wc /staging/mds/mds_repository/${FILENAME4} | awk '{print $1}'`" >> /staging/SOI/dotran/abc.txt

echo "Filename: `ls /staging/mds/mds_repository/${FILENAME5} | cut -d: -f4`" >> /staging/SOI/dotran/abc.txt
echo "RowCount: `wc /staging/mds/mds_repository/${FILENAME5} | awk '{print $1}'`" >> /staging/SOI/dotran/abc.txt

echo "Filename: `ls /staging/mds/mds_repository/${FILENAME6} | cut -d: -f4`" >> /staging/SOI/dotran/abc.txt
echo "RowCount: `wc /staging/mds/mds_repository/${FILENAME6} | awk '{print $1}'`" >> /staging/SOI/dotran/abc.txt
Out put:
Filename: OTA_MASTER_FUA.txt
RowCount: 167174
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
RowCount: 95960
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
RowCount: 386730
Filename: SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
RowCount: 40
Filename: SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
RowCount: 120

This script didn't work.....can someone help please.
/tmp/cat filename.txt

AASP.C0042.S0920.FUA01.CHG.LOG:AN:SNRPZFUA:OTA_CHANGE_LOG_FUA.txt
AASP.C0042.S0920.FUA01.CLIENT.OTA:AN:SNRPZFUA:OTA_MASTER_FUA.txt
SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL


Quote:
#!/bin/ksh

cd /staging/mds/mds_repository
for file in `cat /tmp/cat filename.txt`
do
echo "Filename: `cat $file | cut -d: -f4`" > /staging/SOI/dotran/abc.txt
echo "RowCount: `wc $file | awk '{print $1}'`" >> /staging/SOI/dotran/abc.txt
done
Out put should be like this:
/staging/SOI/dotran/abc.txt

Filename: OTA_MASTER_FUA.txt
RowCount: 167174
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
RowCount: 95960
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
RowCount: 386730
Filename: SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
RowCount: 40
Filename: SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
RowCount: 120

Last edited by dotran; 06-08-2012 at 10:05 AM. Reason: Not wrap.
 
Old 06-07-2012, 01:07 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Would you please use ***[code][/code] tags*** around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.

I can't really tell what's what in your post, and the long lines are making my screen side-scroll. Please go back and edit your post so we can more easily see what's the script, what's the data, and what's the output.

At first glance though, I see quite a bit of commonly-used bad code that should be corrected:
(The linked pages are written for bash, but most of what's in them in them should apply to ksh as well.)

Don't read lines with for!
Don't try to parse ls for filenames
$(..) is highly recommended over `..`

All variable expansions and command substitutions should be quoted, unless you want word-splitting and glob expansion to occur:
http://mywiki.wooledge.org/Arguments
http://mywiki.wooledge.org/WordSplitting
http://mywiki.wooledge.org/Quotes

The cut commands can be replaced with simple parameter substitutions or similar built-in string manipulations.
parameter substitution
string manipulation

The wc+awk combination can be simplified as well. Two possible variations:
Code:
wc -l <"$file"	#no filename is printed if reading from stdin.  Assumes your version of wc has the -l option.
awk 'END{print NR}' "$file"	#simply prints the number of the last record.
The list of separate filename variables should probably be replaced by an array and then looped over, or stored in a separate text file and read into the script from the outside.

http://mywiki.wooledge.org/BashFAQ/005
http://mywiki.wooledge.org/BashFAQ/001
 
Old 06-07-2012, 01:22 PM   #3
dotran
LQ Newbie
 
Registered: Apr 2012
Posts: 27

Original Poster
Blog Entries: 2

Rep: Reputation: Disabled
/tmp/cat filename.txt
AASP.C0042.S0920.FUA01.CHG.LOG:AN:SNRPZFUA:OTA_CHANGE_LOG_FUA.txt
AASP.C0042.S0920.FUA01.CLIENT.OTA:AN:SNRPZFUA:OTA_MASTER_FUA.txt
SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL

This code didn't work....anyone have different idea? Thanks
Quote:
#!/bin/ksh

cd /staging/mds/mds_repository
for file in `cat /tmp/cat filename.txt`
do
cat $file | cut -d: -f4 | sed 's/^/Filename: /'> /staging/SOI/dotran/abc.txt
echo "RowCount: `wc $file | awk '{print $1}'`" >> /staging/SOI/dotran/abc.txt
done
The RowCount didn't work....but the out put need have "Filename:" then "RowCount:". Thanks

Out put should be like this:
/staging/SOI/dotran/abc.txt

Filename: OTA_MASTER_FUA.txt
RowCount: 167174
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
RowCount: 95960
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
RowCount: 386730
Filename: SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
RowCount: 40
Filename: SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
RowCount: 120

Last edited by dotran; 06-08-2012 at 10:05 AM.
 
Old 06-07-2012, 01:32 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Please read my previous post more carefully, and follow the links for advice on how to fix some of the issues in your script. Once you've done that, post your revised version of the script and we can help you with any problems you still have.


And ******USE CODE TAGS******, like I asked !!!
 
Old 06-07-2012, 01:52 PM   #5
dotran
LQ Newbie
 
Registered: Apr 2012
Posts: 27

Original Poster
Blog Entries: 2

Rep: Reputation: Disabled
Thanks Mr. David. Your reply didn't help.

Quote:
#!/bin/ksh

cd /staging/mds/mds_repository
for file in `cat /tmp/cat filename.txt`
do
cat $file | cut -d: -f4 | sed 's/^/Filename: /'> /staging/SOI/dotran/abc.txt
wc `cat /staging/SOI/dontran/don.txt` | awk '{print $1}' | sed 's/^/RowCount: /' >> /staging/SOI/dotran/abc.txt
done
I like the out put should be like this: Thanks
/staging/SOI/dotran/abc.txt

Filename: OTA_MASTER_FUA.txt
RowCount: 167174
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
RowCount: 95960
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
RowCount: 386730
Filename: SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
RowCount: 40
Filename: SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
RowCount: 120

Last edited by dotran; 06-08-2012 at 10:06 AM.
 
Old 06-07-2012, 01:55 PM   #6
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Let's try once again: can you wrap your code in the 'code' tags?!
 
Old 06-07-2012, 03:49 PM   #7
dotran
LQ Newbie
 
Registered: Apr 2012
Posts: 27

Original Poster
Blog Entries: 2

Rep: Reputation: Disabled
/tmp/cat filename.txt
AASP.C0042.S0920.FUA01.CHG.LOG:AN:SNRPZFUA:OTA_CHANGE_LOG_FUA.txt
AASP.C0042.S0920.FUA01.CLIENT.OTA:AN:SNRPZFUA:OTA_MASTER_FUA.txt
SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL


PHP Code:
#!/bin/ksh

cd /staging/mds/mds_repository
for file in `cat /tmp/cat filename.txt`
do
cat $file cut -d: -f4 sed 's/^/Filename: /'> /staging/SOI/dotran/abc.txt
wc 
`cat $file` | awk '{print $1}' sed 's/^/RowCount: /' >> /staging/SOI/dotran/abc.txt
done 
I like the out put should be like this: Thanks
/staging/SOI/dotran/abc.txt

Filename: OTA_MASTER_FUA.txt
RowCount: 167174
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
RowCount: 95960
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
RowCount: 386730
Filename: SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
RowCount: 40
Filename: SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
RowCount: 120

Last edited by dotran; 06-07-2012 at 04:38 PM.
 
Old 06-08-2012, 11:07 AM   #8
dotran
LQ Newbie
 
Registered: Apr 2012
Posts: 27

Original Poster
Blog Entries: 2

Rep: Reputation: Disabled
$ cat /staging/SOI/dontran/don.txt
AASP.C0042.S0920.FUA01.CHG.LOG:AN:SNRPZFUA:OTA_CHANGE_LOG_FUA.txt
AASP.C0042.S0920.FUA01.CLIENT.OTA:AN:SNRPZFUA:OTA_MASTER_FUA.txt
SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL

$ ls -ltr *SNRPZFUA*
-rw-rw-r-- 1 ca7prod users 909351 Jun 8 08:21 AASP.C0042.S0920.FUA01.CHG.LOG:AN:SNRPZFUA:OTA_CHANGE_LOG_FUA.txt
-rw-rw-r-- 1 ca7prod users 29255450 Jun 8 08:21 AASP.C0042.S0920.FUA01.CLIENT.OTA:AN:SNRPZFUA:OTA_MASTER_FUA.txt
-rw-rw-r-- 1 ca7prod users 66980080 Jun 8 08:22 SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
-rw-rw-r-- 1 ca7prod users 269937540 Jun 8 08:22 SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
-rw-rw-r-- 1 ca7prod users 17920 Jun 8 08:22 SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
-rw-rw-r-- 1 ca7prod users 53760 Jun 8 08:23 SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL

This code work, but I like rename the filename output like below.
Quote:
#!/bin/ksh

cat /staging/SOI/dotran/don.txt | while read FILE
do
count=$(wc $FILE | awk '{print $1}')
echo "Filename: $FILE >> filename.txt
echo "RowCount: $count" >> filename.txt
done
cat filename.txt

Filename: AASP.C0042.S0920.FUA01.CHG.LOG:AN:SNRPZFUA:OTA_CHANGE_LOG_FUA.txt
RowCount: 4761
Filename: AASP.C0042.S0920.FUA01.CLIENT.OTA:AN:SNRPZFUA:OTA_MASTER_FUA.txt
RowCount: 167174
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
RowCount: 95960
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
RowCount: 386730
Filename: SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
RowCount: 40
Filename: SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
RowCount: 120

This code not work. Please someone help help......please. The syntax not correct.

Quote:
#!/bin/ksh

cat /staging/SOI/dotran/don.txt | while read FILE
do
count=$(wc $FILE | awk '{print $1}')
#echo "Filename: `cat $FILE | cut -d: -f4`" >> filename.txt
echo "Filename: $FILE | `cut -d: -f4`" >> filename.txt
echo "RowCount: $count" >> filename.txt
#echo "Filename: $FILE\nRowCount: $count" >> /staging/SOI/dontran/file.txt
done
I like the out put should be like this: Thanks
cat filename.txt

Filename: OTA_MASTER_FUA.txt
RowCount: 167174
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
RowCount: 95960
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
RowCount: 386730
Filename: SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
RowCount: 40
Filename: SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
RowCount: 120
 
Old 06-08-2012, 12:49 PM   #9
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
sigh...

For the fourth time... Use CODE tags.
DO NOT USE QUOTE TAGS or other formatting.
(And this isn't php, so don't use php code tags either.)

Put them around ALL of your script and data files.
Use separate code boxes for each individual file or list of data.

EDIT your previous posts to fix their layout.

And DO NOT just keep posting the SAME things over and over.
Only put new and updated info in your following posts.


The links I gave you at first provide all the information you need to fix your script, if you'd just read them carefully. If the English is difficult for you, you can certainly find tutorials in your own language that say the same things. You have to study things for yourself.


But anyway, if only to get you to stop posting the same stuff over and over, I believe this will do what you want:

Code:
#!/bin/ksh

infile="/staging/SOI/dotran/don.txt"
outfile="/staging/SOI/dotran/file.txt"

while read -r file ; do

	file=${file##*:}
	count=$( awk 'END{print NR}' "$file" )

	echo "Filename: ${file##*:}" >> "$outfile"
	echo "RowCount: $count" >> "$outfile"

done <"$infile"

exit 0
I went with awk because I'm still not sure what system you're using, and what options are available to your wc command.
 
Old 06-08-2012, 02:49 PM   #10
dotran
LQ Newbie
 
Registered: Apr 2012
Posts: 27

Original Poster
Blog Entries: 2

Rep: Reputation: Disabled
I ran the code look like wc didn't work. The output "Filename" look good, but wc didn't work. WC on Unix server. Please help again....I so stuck and can't figure this.

Quote:
#!/bin/ksh

infile="/staging/SOI/dontran/don.txt"
outfile="/staging/SOI/dontran/file.txt"

while read -r file ; do

file=${file##*:}
#count=$(wc -l | awk '{print $1}' "$file" )
#count=$(wc `cat $file` | awk '{print $1}')
#count=$(ls `cat $file | sed 's/$/*/'` | awk 'END {print $1}' "$file" )
#ls |cat wc $infile | awk 'END {print $1}' "$file" )
count=$(wc | awk 'END {print $1}' "$file" )
echo "Filename: ${file##*:}" >> "$outfile"
echo "RowCount: $count" >> "$outfile"

done <"$infile"

exit 0
$ cat file.txt
Filename: OTA_CHANGE_LOG_FUA.txt
RowCount:
Filename: OTA_MASTER_FUA.txt
RowCount:
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
RowCount:
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
RowCount:
Filename: SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
RowCount:
Filename: SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
RowCount:

Last edited by dotran; 06-08-2012 at 04:18 PM.
 
Old 06-08-2012, 05:02 PM   #11
dotran
LQ Newbie
 
Registered: Apr 2012
Posts: 27

Original Poster
Blog Entries: 2

Rep: Reputation: Disabled
Okie....I got it work. Thank all.

Quote:
#!/bin/ksh

infile="/staging/SOI/dontran/don.txt"
outfile="/staging/SOI/dontran/file.txt"

while read -r file ; do

#file=${file##*:}
#count=$(wc -l | awk '{print $1}' "$file" )
#count=$(wc `cat $file` | awk '{print $1}')
#count=$(ls `cat $file | sed 's/$/*/'` | awk 'END {print $1}' "$file" )
#ls |cat wc $infile | awk 'END {print $1}' "$file" )
count=$(wc $file | awk '{print $1}')

echo "Filename: ${file##*:}" >> "$outfile"
echo "RowCount: $count" >> "$outfile"

done <"$infile"

exit 0
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
windows: executeable > filename.txt tatoosh Linux - Newbie 10 07-29-2009 06:51 AM
Change name of backup file in ext3 from filename~ to .filename~ Libu Linux - General 2 07-21-2008 09:29 PM
grep from filename.txt can't get the whole line papasj Programming 3 02-25-2008 12:38 PM
Convert static library (Filename.a) to dynamic shared object (filename.so) afx2029 Linux - Software 4 08-17-2007 06:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration