Sem I (Prak Grund Infor) - N4 Flashcards

1
Q

What Bash Kommand “grep” do?

A

Search text or search for patterns within files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Bash Kommand to start with

A
Find all lines in a text file that start with the word "hello"
grep "^hello" file.txt
Quickly replace a string in a previous command and execute it
^old_string^new_string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Das Bash-Linux-Kommando die normalerweise mit dem find-Befehl verwendet, um eine Aktion auf Dateien auszuführen, die durch das find-Kommando gefunden wurden.

A

-exec

find /pfad/zum/verzeichnis -name "dateiname" -exec rm {} \;
Die {} wird durch den Dateinamen ersetzt, und \; gibt das Ende des -exec-Befehls an.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Was macht folgendes regular expression “?”

A

Matching zero or one occurrence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Was macht folgendes Bash Kommand “echo $PPID”

A

PID des Parent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Was macht folgendes Linux Bash Kommand: echo -e

A

Wird verwendet, um Text auszugeben und spezielle Escape-Sequenzen innerhalb des Textes zu interpretieren. ZB. \n und \t

echo -e "Zeile 1\nZeile 2"
Zeile 1
Zeile 2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Что такое Gleitkommazahlen

A

Это числа с плавающей запятой. Числа с плавающей запятой - это вид числового представления, используемого в информатике для представления широкого диапазона реальных чисел. Например: 1,2345 * 10^2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to much whitespace in Linux Bash Regular expression?

A
[[:space:]]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Linux Bash Regular Expression to much alphanumeric Characters

A
[[:alnum:]]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What zcat command in Linux Bash do?

A

Used to view the contents of compressed files without actually decompressing them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to view the contents of compressed files without actually decompressing them in Linux Bash?

A
zcat
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
What following Bash Linux command do: "cat countries.txt <(echo ---------) countries_1.txt"
A

The string “———” is inserted (as if it were the contents of a file).

USA
Canada
Mexico
---------
France
Germany
Italy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What linux bash command cut do?

A

Used to extract sections from each line of input, typically from files or from standard input.

Extract by Byte Position
cut -b 1-4 filename
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to extract sections from each line of input, typically from files or from standard input?

A

cut

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What “cut -b” command do?

A

Extract sections from each line of input
-b (bytes): Select only these bytes from each line.

cut -b 1-4 filename
This command extracts the first 4 bytes from each line of the file filename.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What “cut -c” command do?

A

Extract sections from each line of input
-c (characters): Select only these characters from each line.

cut -c 1-4 filename
This command extracts the first 4 characters from each line of the file filename.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What “cut -d” command do?

A

Extract sections from each line of input
-d (delimiter): Specify a delimiter that separates fields (default is tab).

cut -d ':' -f 1,3 filename
This command uses the colon : as a delimiter and extracts the first and third fields from each line of the file filename.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What “cut -f” command do?

A

Extract sections from each line of input
-f (fields): Select only these fields, separated by the delimiter.

John,Doe,30,Engineer
Jane,Smith,25,Doctor
Jim,Brown,22,Teacher

cut -d ',' -f 1,3 data.txt
-d ',': Sets the delimiter to a comma.
-f 1,3: Specifies that we want to extract the 1st and 3rd fields.

Output:
John,30
Jane,25
Jim,22
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How to sort file for Example alphabetical using Linux Bash?

A
sort filename
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What “sort filename” command in Linux Bash do?

A

This command sorts the lines of the file filename in alphabetical order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How to sort file in reverse order using Linux Bash?

A
sort -r filename
22
Q

How to sort file Numerically using Linux Bash?

A
sort -n filename
23
Q

How to sort file by a Specific Field using Linux Bash?

A
sort -k 2 filename
24
Q

How to sort file by Specify a Field Separator using Linux Bash?

A
sort -t ',' -k 2 filename
25
Q

How to sort file ignoring CASE using Linux Bash?

A
sort -f filename
26
Q

How to sort file Human-Readable Numeric Format using Linux Bash?

A
sort -h filename

This command sorts lines that contain human-readable numbers (e.g., 1K, 2M, 3G).
27
Q

How to sort Remove Duplicates using Linux Bash?

A
sort -u filename
28
Q

How to sort numerically in reverse order using Linux Bash?

A
sort -nr filename
29
Q

What does the Linux Bash command join do?

A

Used to combine lines from two files based on a common field. Similar to a database join.

30
Q

How to join files using Linux Bash command?

A
join file1 file2
30
Q

How to join files based on the common first field using Linux Bash command

A
join file1.txt file2.txt
file1.txt
1 Alice
2 Bob
3 Charlie

file2.txt
1 2000
2 1500
3 3000

Output:
1 Alice 2000
2 Bob 1500
3 Charlie 3000
31
Q

How to join files with delimiter using Linux Bash command

A
join -t ',' file3.txt file4.txt
32
Q

How to join file5.txt on the second field and file6.txt on the first field using Linux Bash command

A
join -1 2 -2 1 file5.txt file6.txt
33
Q

How to join and control which fields to include in the output using Linux Bash command

A
join -o 1.2,2.2 file5.txt file6.txt
34
Q

What does the Linux Bash command tr do?

A

Used to translate or delete characters from the input provided.

35
Q

How to translate characters using Bash Linux.
For example: all lowercase letters to uppercase in the string

A
echo "hello world" | tr 'a-z' 'A-Z'
This command translates all lowercase letters to uppercase in the string "hello world".

===> HELLO WORLD
36
Q

How to delete characters using “tr” and Bash Linux

A

The -d option deletes specified characters from the input.

echo "hello world" | tr -d 'l'
This command deletes all occurrences of the character 'l' from the string "hello world".
===> heo word
37
Q

How to replaces sequences of repeated characters with a single instance using Bash Linux

A
echo "hello     world" | tr -s ' '
This command replaces sequences of spaces with a single space in the string "hello world".
hello world
38
Q

How to combine translation and squeezing of characters using Bash Linux.
For example do this: translates spaces to newlines and then squeezes repeated newlines into a single newline.

A
echo "hello     world" | tr ' ' '\n' | tr -s '\n'
This command translates spaces to newlines and then squeezes repeated newlines into a single newline.
hello
world
39
Q

How to Translate and Delete Characters using Bash Linux
For Example: “hello123 world456” from lower to upper and del all characters exept digits

A
echo "hello123 world456" | tr 'a-z' 'A-Z' | tr -d '0-9'
HELLO WORLD
40
Q

How keeps only the digits from the string using Bash Linux

A
echo "hello123 world456" | tr -cd '0-9'
This command keeps only the digits from the string "hello123 world456"
===> 123456
41
Q

What does the Linux Bash command tee do?

A

Used to read from standard input and write to both standard output and one or more files simultaneously.

42
Q

Runs command, then writes its output to both the terminal and file.txt using Bash Linux.

A
command | tee file.txt
43
Q

Capturing Output to a File While Displaying It using Bash Linux.

A
echo "Hello, World!" | tee output.txt
44
Q

Append to a file instead of overwriting it using Bash Linux.

A
echo "Another line" | tee -a output.txt
45
Q

Writing to Multiple Files using Bash Linux.

A
echo "Hello, again!" | tee file1.txt file2.txt
46
Q

First Show Lists files in long format, writes the output to ls_output.txt, and then filters the list to show only .txt files. using Bash Linux.

A
ls -l | tee ls_output.txt | grep "\.txt"
47
Q

What does the Linux Bash command sed do?

A

Powerful stream editor used for performing basic text transformations on an input stream (a file or input from a pipeline). Searching, replacing, inserting, and deleting text.

48
Q

Replaces the first occurrence of “old” with “new” in each line of the file with sed using Bash Linux.

A
sed 's/old/new/' file
49
Q

Replaces all occurrences of “old” with “new” in each line of the file with sed using Bash Linux.

A
sed 's/old/new/g' file
Substitute with Case Insensitivity
sed 's/old/new/I' file