Operating Systems & Administration
[Day 2] 6. Some more commands
D
DITISS AdminFile Manipulation Commands
Displaying File Content
- Number Lines:
cat -n <filename>- Displays the contents of the file with line numbers.
- View First Lines:
head <filename>- Displays the first 10 lines of the file by default.
- View Last Lines:
tail <filename>- Displays the last 10 lines of the file by default.
- View Specific Number of Lines from Start:
head -6 <filename>- Displays the first 6 lines of the file.
- View Specific Number of Lines from End:
tail -5 <filename>- Displays the last 5 lines of the file.
Extracting Middle Elements
- There is no direct option to print specific middle elements of a file. To achieve this, you need to combine commands, such as using and
head.tail
Sorting and Reversing Content
- Sort File:
sort <filename>- Sorts the file contents in lexicographical order (alphabetically).
- Number-wise Sorting:
sort -n <filename>- Sorts the file contents numerically.
- Reverse File Horizontally:
rev <filename>- Reverses the contents of the file line by line (horizontally).
- Reverse File Vertically:
tac <filename>- Displays the file contents in reverse order (vertically).
- Display Unique Values:
uniq <filename>- Displays only unique values in the file.
- Works only on sorted data and requires consecutive duplicates to be filtered.
Read Next
8/26/2026
[Day 2] 7. Redirection
### Console Standard Files The console operates with three internal standard files: 1. **Standard Input File**: Used to take input. 2. **Standa...
8/26/2026
[Day 3] 1. Revision
### **Process Control Block (PCB) in Linux** - The `task_struct` is a structure used to create the Process Control Block (PCB). - The size of...