More (advanced) commands.¶
awk¶
Powerful, but somewhat more advanced command!
This command finds patterns in a file and can perform arithmetic/string operations. You can use it to transform data files and produce formatted reports.
It allows the user to use variables, numeric functions, string functions, and logical operators.
Things awk
can do:
- Scan a file line by line
- Split each input line into fields
- Compare input line/fields to pattern
- Perform action(s) on matched lines
Search for the pattern ‘snow’ in the file FILE and print out the first column
Print column 2 and 3 from file mydata.dat, but only those rows that contain the letter ‘r’
chown - change ownership¶
To change ownership of a file or directory, use the command chown
.
Examples
chown USERNAME FILE
the user with USERNAME becomes the new owner of FILEchown USERNAME DIRECTORY
the user with USERNAME becomes the new owner of DIRECTORY (but not any subdirectories)chown USERNAME:folk DIRECTORY
the user ownership is changed to USER and the group ownership to group “folk” for the directory DIRECTORYchown :folk DIRECTORY
the group ownership is changed to the group “folk” for the directory DIRECTORYchown -R USERNAME:folk DIRECTORY
the user ownership is changed to USERNAME and the group ownership is changed to group “folk” for the directory DIRECTORY and all subdirectories
Warning
As default, chown
does not generate output on success and returns zero.