Podcast
Questions and Answers
What does the grep command do by default?
What does the grep command do by default?
- Prints out the matching lines. (correct)
- Counts the number of matches found.
- Prints the line numbers of matches.
- Ignores case sensitivity.
Which grep option would you use to find lines that do NOT match a specific pattern?
Which grep option would you use to find lines that do NOT match a specific pattern?
- -c
- -n
- -v (correct)
- -i
How can you ignore case sensitivity in a grep search?
How can you ignore case sensitivity in a grep search?
- By using the -i option. (correct)
- By using the -v option.
- By using the -n option.
- By using the -c option.
What is the output of the command 'sort input1.txt input2.txt > output.txt'?
What is the output of the command 'sort input1.txt input2.txt > output.txt'?
Which command is most effective to remove adjacent duplicate lines from a sorted file?
Which command is most effective to remove adjacent duplicate lines from a sorted file?
Flashcards are hidden until you start studying
Study Notes
LINUX File System Overview
- LINUX uses a hierarchical tree structure for its filesystem, starting from the root directory (
/
). - Each directory can have multiple child directories but only one parent directory.
- Paths can be absolute (from root) or relative (from the current directory).
Listing LFS Directories
- The
ls
command displays current directory contents; it lists visible files and directories by default. - Hidden files (starting with a period) can be shown using
ls -a
, which lists all entries, including.
(current) and..
(parent) directories.
I-node Structure
- An i-node is a data structure that stores file metadata, including ownership, location, and pointers to file blocks.
- Each partition has its own set of i-nodes, allowing files with the same i-node number in different partitions.
- Use
ls -i
to display i-node numbers for files in the current directory.
Hard and Symbolic Links
- Links are a file name combined with an i-node number, allowing access to files from different locations.
- Hard links are direct duplicates of the original file; symbolic links point to the original file's location.
- Create symbolic links with
ln -s existing_file new_file
.
Finding Files
- Use the
find
command to search for files by name within a directory tree. - Example to find
.txt
files:find /home -name "*.txt" -print
. - Find can filter files by type, permissions, size, etc., and can execute commands on found files with the
-exec
option.
Finding Text in Files
- The
grep
command searches for text patterns in files. - Basic syntax:
grep options pattern files
, where options can modify behavior (e.g.,-c
counts matches,-i
ignores case). - Combine
grep
withfind
to search through files in directory trees (e.g.,grep hello \
find . -name "*.txt" -print``).
Sorting Files
- The
sort
command organizes file contents alphabetically or numerically. - To output sorted results to another file, use redirection (e.g.,
sort input1.txt input2.txt > output.txt
). - The
uniq
command removes adjacent duplicate lines from a file, often used aftersort
for streamlined output (e.g.,sort input.txt | uniq > output.txt
).
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.