Sem I (Prak Grund Infor) - N5 Flashcards
Deletes the second line of the file with sed using Bash Linux.
sed '2d' file
Prints only the second line of the file with sed using Bash Linux.
sed -n '2p' file
Inserts “new line” before the second line of the file with sed using Bash Linux.
sed '2i\new line' file
Appends “new line” after the second line of the file with sed using Bash Linux.
sed '2a\new line' file
Replace Text Between Two Patterns: sed '/start/,/end/s/old/new/' file
Replace Text in a File and Save to a New File: sed 's/old/new/g' input.txt > output.txt
Delete All Lines Containing a Pattern: sed '/pattern/d' file
Print Lines Matching a Pattern: sed -n '/pattern/p' file
What does Linux Bash command “crontab” do?
The crontab command in Linux is used to schedule tasks to run at specified times or intervals. These tasks are called “cron jobs” and are defined in a file known as the crontab file.
What does Linux Bash command “uniq” do?
Used to filter out or report duplicate lines in a sorted file or input.
This command reads from filename and outputs unique lines, filtering out adjacent duplicate lines. uniq filename
Prefixes for each line with the number of occurrences using Bash Linux.
uniq -c filename
Show Only Duplicate Lines using Bash Linux.
uniq -d filename
Show Only Unique Lines using Bash Linux.
uniq -u filename
What does the Linux Bash command “paste” do?
Used to merge lines of files horizontally (side-by-side).
paste file1 file2
What does the Linux Bash command “seq” do?
Used to generate a sequence of numbers. It can be used to create lists of numbers.
paste <(seq 1 5) <(seq 11 15) <(seq 21 25) 1 11 21 2 12 22 3 13 23 4 14 24 5 15 25
seq [options] FIRST LAST seq 1 5 1 2 3 4 5
seq 1 2 9 1 3 5 7 9
seq -s "," 1 5 1,2,3,4,5
What does the Linux Bash command “nl” do?
Used to number the lines of a file.
nl filename Output: 1 apple 2 banana 3 cherry 4 date
How to write a number the lines of a file using Linux Bash?
nl filename
What does the Linux Bash command “tac” do?
Used to concatenate and print files in reverse, line by line.
apple banana cherry date tac example.txt date cherry banana apple
What does the Linux Bash command “column” do?
Used to format text into columns. It takes input from standard input or a specified file and organizes the data into neatly aligned columns.
apple 1 banana 2 cherry 3 date 4 column data.txt apple 1 banana 2 cherry 3 date 4
What does the Linux Bash command “colrm” do?
Used to remove columns from a file or standard input.
colrm start This command removes all characters starting from column start to the end of each line.
colrm start end This command removes all characters from column start to column end inclusive.
What does the Linux Bash command “od” do?
Used to display data in various binary formats, such as octal, hexadecimal, decimal, and ASCII.
od example.txt 0000000 110401 114503 115510 054040 127507 162154 100041 0000016 The default output displays the data in octal format.
Hexadecimal Output od -x example.txt