OSY8
OSY8
1. rm (Remove)
Theory:
The rm command is used to remove (delete) files or directories. By default, rm only deletes files. If
you want to delete directories, you must use the -r (recursive) option.
Usage:
2. mv (Move)
Theory:
The mv command is used to move or rename files and directories. When used to rename, it changes
the file name. When used to move, it moves the file from one location to another.
Usage:
3. cp (Copy)
Theory:
The cp command is used to copy files or directories. By default, it copies the contents of a file to a
new file. To copy directories, the -r option is used to copy recursively.
Usage:
4. join
Theory:
The join command is used to join two files based on a common field. It works by matching lines from
the two files based on a key field and combines them into a single output.
Usage:
join file1 file2 # Joins file1 and file2 on their common field
5. split
Theory:
The split command is used to split a large file into smaller files. By default, it splits files into chunks of
1000 lines, but you can specify the size.
Usage:
split -l 1000 large_file new_prefix # Splits by lines, with a custom prefix for output files
6. cat (Concatenate)
Theory:
The cat command is used to display the contents of a file, combine multiple files, or create new files.
It can be used to quickly view file contents.
Usage:
cat file1 file2 > combined_file # Concatenates file1 and file2 into combined_file
7. head
Theory:
The head command is used to display the first few lines of a file (by default, the first 10 lines).
Usage:
8. tail
Theory:
The tail command is used to display the last few lines of a file (by default, the last 10 lines). It is often
used to view logs in real time by using the -f option.
Usage:
9. touch
Theory:
The touch command is used to create empty files or update the timestamp of existing files. If the file
doesn’t exist, it will create an empty file.
Usage:
• join → Not directly available in Windows, but can use findstr or PowerShell scripts.
• split → fsutil: Windows does not have a direct split command, but fsutil can be used to
manipulate file sizes.
• head → Not directly available in Windows, but PowerShell can be used for similar
functionality (e.g., Select-Object -First 10).
• tail → get-content: PowerShell’s Get-Content cmdlet with the -Tail option simulates tail.