- The problem statement, all variables and given/known data:
So i'll probably get told off for this but I have a few problems and rather than clog up the whole forum I'll post them here. Please bare in mind I am a complete novice when it comes to all this and so if you help please treat me like a complete idiot
I have a text file of names and test scores called class.txt e.g.
Bob Smith 15
James Jones 25
Emily Hunt 70
Then another text file with more detail called classdetails.txt e.g. (note the subject, date, first and surname, class, scores are separated by tabs, also the names are one field not two)
Maths 10/05/12 Bob Smith Class 5 65:54:32:96
English 15/04/12 James Jones Class 7 84:64:83:38
Science 12/07/13 Emily Hunt Class 9 73:28:95:07
Then finally a text file called test.txt that simply contains
qwertyuiop
I have done half of the exercise and am really struggling with the rest of the questions. We are told to use awk from the command line,
6)Print all of the contents of the file (class.txt) and give a title to each column and separate out each column with a tab, send he output to another file.
7)Print out all of the students who have scored over 30 and redirect the output to sort to display alphabetically.
8)Print out all of the students and redirect the output to sort to display in order of their score.
9)Use colrm on a copy of the file test.txt to remove the last column.
10)Use colrm on a copy of the file test.txt to remove columns 3 to 5.
11)Print �testing� five times using awk.
12)Using the classdetails.txt file print col 5 and then sort the output in numerical order. Note this file is tab separated - hint use sort to sort the output from awk.
13)Create 4 files with the suffix .txt in your home directory. Create a sub-directory. Using awk and the UNIX shell move all of the .txt files to the sub-directory.
- Relevant commands, code, scripts, algorithms:
I have a very basic knowledge of things like awk, grep, sort and pipes but other than that I'm clueless.
- The attempts at a solution (include all code and scripts):
To print all of the contents of the file I have tried
awk �{print}' class.txt > class2.txt
and then perhaps edit the file with nano although I'm sure there is a better way.
Question 7 I imagine is largely similar to 6 except instead of the " > class2.txt" perhaps something involving pipes ??
Question 8 the same as above except using pipes to sort i.e. | sort -l
Question 9 and 10 I have no clue about colrm so again any help appreciated.
Question 12 will be similar to 6 I think
Question 13 No clue.
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Northern Illinois University, DeKalb (IL), United States, Raymond Ege, CSCI330
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).