Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk and cut

Status
Not open for further replies.

superstarjpmc

Programmer
Jan 22, 2004
38
US
hi,
i have a requirement where inside an awk script i need to execute a unix 'ls -l' to pick the file/directory permission, user name, group name,filename,date,etc.

When i use a cut, i'm afraid that it might not provide me the right results as i use the delimiter .. -d' '.. this will obviously fetch a wrong result depending on the file created time,size etc.. which alters the white spaces..

Guess i have explained my requirement properly !..

what i have done ..
.........
.........
x4 contains the output of 'ls -ld <file/dir name>'

x5[0]= x4 " | cut -f1 -d \" \" ";
x5[1]= x4 " | cut -f5 -d \" \" ";
x5[0] | getline o5[0];
x5[1] | getline o5[1];

print o5[0];
print o5[1];

.........
.........



i thought of using 'awk' instead of 'cut'..but i dont know how to use an awk inside an awk script ..

any help much appreciated.
 
In the awk man page pay attention to the split function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top