Quote:
Originally Posted by imagineers7
Hi johnsanty,
Are you lookin for this:-
ls -l | awk '{ print $3 }'
Which prints the third fields of the following
-rw-rw-r-- 1 aniruddha aniruddh 21903360 Feb 20 16:40 firefox-1.5.0.1.tar
-rw-rw-r-- 1 aniruddha aniruddh 1312768 Feb 21 10:00 abcd.pdf-rw-rw-r-- 1 aniruddha aniruddh 431149 Feb 21 09:53 bds.zip
ie. the owner of the files:-
aniruddha
aniruddha
Have fun
|
Hi imagineers,
Thank you so much for replying.
Here's what I did.
#####################################
awk '{ print $1 }' number_lines
echo "The number of line is $1"
#####################################
Basically, the number_lines file contains the following:
~~~~~~~~~~~~~~~~~~~~
3 textfile
~~~~~~~~~~~~~~~~~~~~
The first line of my code works perfectly but I want to extract the value of the $1, which is 3, and use it in my for loop. I tried different things like the following:
Try1:
##########################################
awk '{ temp=$1 }' number_lines
echo "The number of line is $temp"
#########################################
Try2:
##########################################
awk '{ let temp=$1 }' number_lines
echo "The number of line is $temp"
#########################################
Try3:
##########################################
awk '{ $((temp=$1)) }' number_lines
echo "The number of line is $temp"
#########################################
They all failed. Could you give some hints on how to extract that value of $1. thank you in advance...