How to strip off the leading filename from 'wc -l' command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to strip off the leading filename from 'wc -l' command
# 1  
Old 03-23-2011
How to strip off the leading filename from 'wc -l' command

Hi... can anyone please tell how do i strip off the leading filename from the wc -l command....

when i fire command
Code:
wc -l new1

... its giving output as

Code:
     14 new1

i want the output as just '14'...

i need to use this value in the calculations in the later part of the script..

thanks in advance,
Swapnil

Last edited by joeyg; 03-23-2011 at 03:41 PM..
# 2  
Old 03-23-2011
awk as one option

Code:
wc -l new1 | awk -F' ' '{print $1}'

or
Code:
wc -l <new1

This User Gave Thanks to joeyg For This Post:
# 3  
Old 03-23-2011
thank you...

i used the second code and got the output as i wanted...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strip leading and numbers from a string.

Hello I have two vars loaded with $VAR1="ISOMETHING103" $VAR2="COTHERTHING04" I need to: 1) Strip the first char. Could be sed 's/^.//' 2) The number has it's rules. If it has "hundreds", it needs to be striped. If it is just two digits it shouldn't. So, for VAR1 output should be... (7 Replies)
Discussion started by: tristezo2k
7 Replies

2. Shell Programming and Scripting

how to remove leading directory from line in filename?

i have a process that receives files similar to below. these are files obviously generated on a windows machine that are submitted to a linux cluster. the one thing they have in common is the leading c:\any-number-of-leading-dirs\filename.xxx. is there a way to re-create/modify the file to remove... (3 Replies)
Discussion started by: crimso
3 Replies

3. Shell Programming and Scripting

Untar specific directory and strip leading directories

Ok so I know the title was probably confusing so here goes: I have a tarball (gzipped) that has a nested directory structure . For example: my.tar.gz (contents) --- ------ --------- ------------ --------------- ... (2 Replies)
Discussion started by: DC Slick
2 Replies

4. Shell Programming and Scripting

Help with adding leading zeros to a filename

Hi i need help in adding leading zero to filenames e.g file name in my folder are 1_234sd.txt 23_234sd.txt the output i need is 001_234sd.txt 023_234sd.txt can i do this shell scripting please help (2 Replies)
Discussion started by: rsmpk
2 Replies

5. UNIX for Dummies Questions & Answers

Strip part from filename

I've many file like this 01-file 01_-_file 01_-_file 01_-_file 01_-_file 01-file I would remove bold part from filename. Suggestions?Thanks (4 Replies)
Discussion started by: cv313x
4 Replies

6. Programming

Strip command

I am new in Unix. I go through the man strip. But did not understand that, why when we have -G (debug and release ) option in the compiler, than using strip command to strip the debug information from the objects. i want to binary for teh production i will compile it without debug option. What the... (4 Replies)
Discussion started by: Saurabh78
4 Replies

7. UNIX for Advanced & Expert Users

strip command

I have created one binary with the debug option debug.out and another without it is production.out. Now, i use stripe on the debug.out. Now, both binary will be same? or have any differences. (1 Reply)
Discussion started by: Saurabh78
1 Replies

8. Shell Programming and Scripting

Strip extention from filename

Hey, How to strip the extention from filename? MY_XML.xml -> MY_XML MY_TEST_FILE.txt -> MY_TEST_FILE HELLO_WORLD.xls -> HELLO_WORLD Thanks in advance! (2 Replies)
Discussion started by: mpang_
2 Replies

9. Shell Programming and Scripting

Strip leading and trailing spaces only in a shell variable with embedded spaces

I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help. echo $SH_VAR | command_line Syntax. The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies
Login or Register to Ask a Question