question 6 is basically adding a header. you can use a special block called a BEGIN block in awk to to do. for example
awk 'BEGIN { print "name\tid"; } 1 { print $0; }' class.txt
You've not shown much work on the rest.
awk works with fields. You seem to understand how to change the field separator. If you want to print every record where column 5 is greater than 30, you'd use something like
awk '$5 > 30'
awk code follows the syntax
condition { action }. The default condition is 1 (or always true) and the default action is
print $0. Thus, the above example is equivalent to
awk '$5 > 30 { print $0 }'.
Have a look at
man sort and you will see how to sort on certain fields as well. Make sure to use
-n for numeric sort where needed.
The questions involving making a directory and moving files shouldn't require awk. awk is a text processor. Unless those files are to be made with certain text or are part of the other questions output... In the shel you'd use
mkdir and
mv to make a directory and move files, respectively.
Moderator's Comments:
|
|
This post was originally submitted to a duplicate thread.
|
|