PDA

View Full Version : [ubuntu] output of a commend in a veriable ???



just_linux
August 10th, 2008, 10:06 PM
Ok :popcorn:
here is the issue : I wrote a program and I want inside of the program check if a file called "ADDRESS" has any line or it is empty and if it is, do something ...

I know I might need to use wc -l Adrress or something But I do not know how should I put it in a variable like $output? or how can I just get the number instead of number address?


how can I put
output= wc -l address? and how can I just get the number?:lolflag:
Please help :guitar:

scorp123
August 10th, 2008, 11:19 PM
export VARIABLE=`wc -l file_to_be_counted.txt | awk '{ print $1 }'`
> echo $VARIABLE
567


Voila :)

lisati
August 10th, 2008, 11:22 PM
Some versions of C have a function to set environment variables. If memory serves correctly, it's usually called something like setenviron()
The corresponding function to read the variable is getenviron()