HomeToolsAbout

Linux

cat

Read the contents of a file in console

cat filename.txt

Override the contents of another file

  • If the destination file does not exist then the command will create it, or overwrite an existing one by the same name
cat source.txt > destination.txt

Concatenate multiple files to one

cat source1.txt source2.txt > destination.txt

grep

By default, the grep command outputs entire lines that contain the match.

  • returns the lines of the text file which contain the matching search string.
grep "search_string" filename

A line in a text file is a sequence of characters followed by a line break.

Recursively Find/Delete Files

Find and list all .DS_Store in current folder recursively

find . -name ".DS_Store"

Delete all files that are recursively matching from current directory.

  • -type f is a tag to filter only for files, excluding directories
find . -name ".DS_Store" -type f -delete

$home

Represents user's home directory regardless of where it is being called from.

  • Home can be different per OS (e.g. Mac and Linux have different home directories)

$home is same as ~.

std

AboutContact