So this is a completely different problem than what you described in the 1st post in this thread. All of the lines you showed us in that post:
are now to be counted as Junk and the counts of all of the other three categories (using your sample input) are to be zero.
So, the following totally untested code (since we have no samples to test) might do what you want:
Notes:
The code in red adds the Total Records printout that the script you showed us in post #13 in this thread produced. If you no longer want that to be included in your output (as shown in post #17 in this thread), remove the code shown in red.
This code assumes that no more than one of the strings you're looking for will occur on any single line.
If the files named in file.txt are Excel spreadsheet files (as implied by your name for your temporary file), this awk script (and your series of grep commands) will not work.
I changed the name of your output file from final_count.xls to final_count.txt because your requested output is a text file; not an Excel spreadsheet file.
I redirected your script's diagnostic message to stderr instead of stdout.
I create (or overwrite) your output file instead of appending to the current contents. If you really want the output from multiple runs of your script to append, change the > in the last line of the awk command to >>.
If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk.
This User Gave Thanks to Don Cragun For This Post:
Hello!
I'm trying to find out the total file size of a subset list in a directory. For example, I do not need to know the total file size of all the files in a directory, but I need to know what the total size is of say, "ls -l *FEB08*" in a directory. Is there any easy way of doing this?
... (3 Replies)
Hi All,
I'm developing a FTP script as below:
ftp -v -n <IP_ADDRESS> << EOF
user avery jSqaqUU2
lcd /directory/folder/
ascii
prompt
mget *
bye
EOF
I would like to enhance the script to count the total file downloaded. For example, once the script run i want the message "Total <n>... (1 Reply)
Started using unix commands recently.
I have 50 gzip files. I want to grep each of these files for a line count based particular category in column 3. How can I do that?
For example
Sr.No Date City Description Code Address
1 06/09 NY living here 0909 10st st nyc
2 ... (5 Replies)
I have different things that I was trying to do but am kind of struggling with this since I'm a Linux noob. I have a files with student names ,marks,year school the . What is the most efficient way to get a total count of students and student with highest marks
Initially I tried to get a count... (1 Reply)
How to find count total number of pattern in a file …
File contains : a.txt
-------------
aaa bbb nnn
ccc aaa bbb
aaa ddd aaa
aaa aaa aaa
grep -c aaa a.txt
Op: 4 ( But my requirement is should count the total no of patterns as 7 ) (4 Replies)
Hi all,
I have found another post threads talking about count duplicate lines, but I am interested in obtain the total number of duplicates. For example:
#file.txt
a1
a2
a1
a3
a1
a2
a4
a5
#out
3 (lines are duplicates)
Thank you! (12 Replies)
Hi all, I have a file that contains characters. How do I get total of spesific character from that file and save the count to a variable for doing for calculation.
data.txt
1
2
2
2
2
3
3
4
5
6
7
8
5
4
3
4 (5 Replies)
Hi All ,
We need one help on the below requirement.We have multiple pipe delimited .txt file(around 100 .txt files) present on one directory.We need the total record count of all the files present in that directory without header.File format as below :
... (8 Replies)