Computing.Net > Forums > Unix > Output redirecting!!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Output redirecting!!

Reply to Message Icon

Name: drc--ro-w
Date: April 8, 2004 at 10:21:12 Pacific
OS: Windows XP (Home)
CPU/Ram: Intel Mobile Pentium IV 1
Comment:

How do a redirect and output of a command to a variable:
For example:
wc -l < text

how do i store the output in, let's say variable 'count'

Thnx



Sponsored Link
Ads by Google

Response Number 1
Name: aigles
Date: April 8, 2004 at 11:13:21 Pacific
Reply:

You can do :

count=`wc -l <text`

The problem is that there are leading spaces before the count value, if you want to remove then you can do :

count=`wc -l <file | awk '{print $1}'`

Jean-Pierre.


0

Response Number 2
Name: nails
Date: April 8, 2004 at 15:32:05 Pacific
Reply:

Hi:

If you are using ksh, you can remove the white space by just adding zero:

yy=$(($(wc -l < text) + 0))

Regards,

Ed


0

Response Number 3
Name: aigles
Date: April 9, 2004 at 00:52:55 Pacific
Reply:

The + 0 is not necessary, you can do :

yy=$(($(wc -l <text)))

Jean-Pierre.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Output redirecting!!

Cannot capture the ufsdump output www.computing.net/answers/unix/cannot-capture-the-ufsdump-output/3794.html

Exclude Certain Entries the Output www.computing.net/answers/unix/exclude-certain-entries-the-output/8326.html

Check for new file, exec sql*plus www.computing.net/answers/unix/check-for-new-file-exec-sqlplus/6714.html