Bash Commands Flashcards
(114 cards)
vim -r
list swap files
tail ‘file’
shows last 10 lines of the file
vim
open or creates file
mv ‘file1’ ‘file2’
move file to destination or rename file
cp ‘file1’ ‘file2’
copy contents from file1 to file2
rm ‘file’
remove a file
rm -r ‘file’
remove a file recursively
rm -d
remove empty directory
rm – -foo
rm file that starts with foo
find . -name ‘file1’ -type d
find the directory called file1. Without the -type d, it will search for files and directories
diff ‘file1’ ‘file2’
compares files and shows where they are different
sort -n -r ‘file’
sort files, -n for numeric sort and -r for reversing order
rev
reverse string character
chmod +wrx
reach, write and execute permissions
chmod -o -g -a -u
removes permission for others not in group, group, all users and user
lpr ‘filename’
prints the file
grep -i ‘hello’ ‘filename’
search for hello in filenames (this will not be case-sensitive)
grep -r ‘hello’ ‘directory
search recursively for pattern in the directory
sed ‘s/hello/goodbye/g’ ‘filename’
This will replace all occurrences of hello with goodbye in ‘filename’ without modifying the file
sed -i ‘s/dog/cat/g’ file.txt
replaces “dog” with “cat” in file.txt and saves the change
echo “this” | sed ‘s/is/at/g’
replaces “is” with “at” in the input string “this”
mkdir ‘filename’
makes a new directory
rmdir -rf
removes a non-empty directory
cp -r ‘dir1’ ‘dir2’
copy dir1 into dir2 including subdirectories