![]() su -c to the user and change directory/file permisions to 777. Extract the user name(3rd field) and the directory/file name(9th field) using awk and save them into variables. Using ksh on AIX what I am trying to do is to read the ls -l output from a file in a do while loop line by line. I showed previously how to do it using sed and perl. A more interesting task is to extract every nth line from a text file. Note that this hack will not work if multiple lines are being extracted. If the text file is huge, you can cheat by exiting the program on the first match. Using awk to extract lines in a text file. List Group Membership of a User → Shell Scripting: How to Read a File Line by Line in a Shell Script. Solutions, Tips and HowTos for all kinds of (mostly) technology related problems that come my way. ![]() Read file line by line and remember the last position in file. Browse other questions tagged shell-script awk read or ask your own question. Read a file line by line and if condition is met continue reading till end. If you need to explicitly read a lines from a file, look at 'getline()' in the gawk info file. Awk reads the file(s) in the argument, or from the pipe input. 'awk -f awkscript' The filename argument after the -f option is the awk script to run, not the file or files to scan.
0 Comments
Leave a Reply. |