Count aggregated command output using wc -l


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Count aggregated command output using wc -l
# 1  
Old 10-13-2011
Count aggregated command output using wc -l

Hi all,

I need to run a bunch of commands seperated by ; but then count the total lines of output. Pipes and redirection don't seem to be helping me. Anyone know how I can do this properly:

Code:
ls /usr/bin/nslookup ; ls /usr/sbin/lsof ; ls /sbin/ifconfig ; ls /usr/sbin/dmidecode ; ls /sbin/ethtool ; ls /bin/netstat | wc -l

... assuming all files exist I would like to see '6' as the result. But I get '1' because it's not aggregating the output all the way to the wc. Same result if I use & or > between commands instead of ;

Help?
# 2  
Old 10-13-2011
Code:
ls /usr/bin/nslookup /usr/sbin/lsof /sbin/ifconfig /usr/sbin/dmidecode /sbin/ethtool /bin/netstat | wc -l

--ahamed

---------- Post updated at 08:49 PM ---------- Previous update was at 08:48 PM ----------

And why it was giving 1 is because, wc -l is piped only to the last ls /bin/netstat command

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 3  
Old 10-13-2011
Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sql query output count

Hi Team, below sql rerturn 20 records, the result set i am going to assign to one variable and it showing count is 1. and i don't use count() in sql query... based on count, i need to fail the script. No_of_step=`echo ${g_count} | wc -l` function gf_count() { g_count=`sqlplus -s... (8 Replies)
Discussion started by: bmk123
8 Replies

2. Shell Programming and Scripting

awk output is not the correct count

The awk below runs and produces the following output on the file2. This is just an example of the format as the file is ~14MB. file1.txt is attached. I am trying to count the ids that match between the two files and out the ids that are missing. Thank you :). file2 970 NM_213590 ... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

Insert title as output of command to appended file if no output from command

I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place. What I need The following command is placed at the prompt: TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies

4. Shell Programming and Scripting

How to count number of characters of wc -l output?

I want count number of characters / find the length of the 'wc -l' output This is the command bash-3.2$ gzcat /home/sid/file1.dat |wc -l 830752 So final out I want is 6 i.e lenght of 830752 I tried with awk bash-3.2$ gzcat /home/sid/file1.dat |wc -l | awk '{print length ($0)... (3 Replies)
Discussion started by: sidnow
3 Replies

5. AIX

Aggregated Etherchannel

Hi, I have a AIX5.3 P6-520 with 8x1Gb Ethernet ports with possible connections to 2 CISCO 2960 switches. I can create 8023ad Etherchannels which work correctly with the switches (I have set up for LACP passive and a valid channels) But can create 2x 8023ad 4Gb Etherchannels with no backups.... (2 Replies)
Discussion started by: spitzie
2 Replies

6. UNIX for Dummies Questions & Answers

How to assign multiple IPs to Aggregated interface in Solaris 10?

I have 2 physical interfaces (bnx0 and bnx1) aggregated into aggr1. I need to assign second IP, and normally I know how to do it to physical interface (i.e. bnx0:1) however same trick (aggr1:1) is not working. Is there any way to do it? (0 Replies)
Discussion started by: bratan
0 Replies

7. Shell Programming and Scripting

Aggregated points

Combine points of specific key (a1) based on user defined size (lets say 200 in this example). so a1 191 and 191+200 and sum of all the values (4th column) and vice versa... Thanx a bunch! a1 191 201 1 a1 201 211 2 a1 211 221 1 a1 ....... .... a2......... ........ (7 Replies)
Discussion started by: quincyjones
7 Replies

8. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies

9. UNIX for Dummies Questions & Answers

Word Count without any characters but the Output String

Hi all, I am logging any access to a server, and i wanted to write a script which tells me how much entries there are. The Problem is that "wc -l log" outputs the correct number of lines but with the name of the file attached. is there any nice possibility to solve this that i ONLY... (3 Replies)
Discussion started by: JP_II
3 Replies
Login or Register to Ask a Question