nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
set alias "cats" for command 'konqueror http:'//icanhazcheezburger.com''
alias cats='konqueror http:'//icanhazcheezburger.com''
Display permissions, user, group, and full path for each file in the current directory tree as a list
tree -p -u -g -f -i
Run perl -V in an empty environment.
env -i perl -V
find file named foo.txt under root / directory.
find / -name foo.txt
Display file type description of 'file-name' based on contents.
file file-name
Find all the files named 'vimrc' anywhere on the system
find / -name vimrc
Removes files 'junk1', 'junk2', 'junk3'.
rm junk1 junk2 junk3
Find recursively all files under current directory tree that contain a colon in the filename
find . -name \*\:\*
lines.txt contains a list of line numbers, one entry per line - output only these lines from text.txt omitting the rest of the file.
cat -n text.txt | join -o2.2 lines.txt -
Send 5 ping requests to address 12.34.56.78 and print only the last 2 lines of the summary output.
ping -c 5 -q 12.34.56.78 | tail -n 2
Print content of all files found regarding seach options '[whatever]'
find [whatever] -exec cat {} \;
Move all *.php~ files under current directory to /mydir
for D in `find . -iname "*.php~"`; do mv ${D} /mydir; done
Check if $path_in_question is mount point of filesystem
df $path_in_question | grep " $path_in_question$"
Find and remove zero bytes files from user's directories .
find /usr/* -size 0c -exec rm {} \;
find all the regular/normal files in the folder "myfiles" which have the permission 647.
find /myfiles -type f -perm -647
Print host name without a newline
echo -n `hostname`
Continuously send "y" to input of "command-that-asks-for-input"
yes | command-that-asks-for-input
Make directories and parents as needed for each unique second "&" delimited field with " ", ",", and ":" removed in "filetypes.txt"
mkdir -p `cut -f2 -d"&" filetypes.txt | sed 's/[ ,:]//g' | sort -u`
Go back to last directory.
cd -
Removes files 'junk1', 'junk2', 'junk3'.
rm junk1 junk2 junk3
Find all files and directories starting from the current directory and excluding hidden files and directories
find . \( ! -regex '.*/\..*' \) | sed 's/^..//'
Find regular files in the current directory tree that have any executable bits set
find -L . -type f \
Find all files on the system that are world writable
find / -wholename '/proc' -prune -o -type f -perm -0002 -exec ls -l {} \;
search for a word in all the regular/normal files in the entire filesystem. ( + is used to give more than one file as input to the grep command.
find / -type f -exec grep -i 'the brown dog' {} +;
Read a line from standard input into variable "REPLY" with prompt "$*"
read -p "$*"
Archive "src/bar" on host "foo" to local directory "/data/tmp"
rsync -avz foo:src/bar /data/tmp
searches through the /usr directory for the regular file named 'Chapter1*'
find /usr -name "Chapter*" -type f
Recursively change the group ownership to "laravel" in "./bootstrap/cache"
sudo chown -R :laravel ./bootstrap/cache
Find all files under /path/to/base/dir and change their permission to 644
find /path/to/base/dir -type f -exec chmod 644 {} +
List all file details with filenames matching "*2012*.xml" from "serveripaddress::pt/dir/files/" listening on port 111 and write to "output.txt"
rsync --list-only --include "*2012*.xml" -exclude "*.xml" serveripaddress::pt/dir/files/ --port=111 > output.txt
find all the files starting with "config" in the folder Symfony
find Symfony -iname '*config*';
Create a symbolic link named "/usr/local/bin/subl" to "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Find files in the current directory tree whose permissions are 775
find . -perm 775
Calculate the md5 sum of the tar archive of "dir"
tar c dir | md5sum
find all the mp3 files in the home folder which have been modified today
find ~ -type f -mtime 0 -iname '*.mp3'
Remove all tmp/*.mp3 files
find tmp -maxdepth 1 -name '*.mp3' -maxdepth 1 | xargs -n1 rm
Add group write permission to all files in the current directory
find . -maxdepth 0 -type f -exec chmod g+w {} ';'
Find directories named `doc' in /usr and below
find /usr -name doc -type d
Find files/directories under /tmp smaller than 100 bytes
find /tmp -size -100c
display all the files in the user folder which have been modified after the files /tmp/stamp$$
find /usr -newer /tmp/stamp$$
find all directories with the name "lib64" in the usr folder and replace space with ':'
find /usr -name lib64 -type d|paste -s -d:
Show human-readable file type description of file "/mnt/c/BOOT.INI"
file /mnt/c/BOOT.INI
Join lines in file "aa" with lines in file "bb" if the lines share a common first word and sort the result numerically
join <(sort aa) <(sort bb) | sort -k1,1n
Print the list of files modified within a fortnight ago removing the leading ./ from the file names
find . -mtime -14 | sed -e 's/^\.\///'
Search for files only that end with .php and look for the string $test inside those files
find . -name \*.php -type f -exec grep -Hn '$test' {} \;
Find all PHP files under current directory
find . -type f -name *.php
Search for aaa in all files under current directory and count the number of matches
find . -type f -exec grep -o aaa {} \; | wc -l
change permissions of files older than 30 days
find /path/to/directory -type f -mtime +30 -exec chmod 644 {} +
Lists all files in a current folder, separating names with comma.
ls | sed '$!s/$/,/' | tr -d '\n'
Use ANSI escape codes to make "World" bold from input "Hello World!"
echo 'Hello World!' | sed $'s/World/\e[1m&\e[0m/'
Merge lines whose first comma-separated field in file 'in1' also appears as a first comma-separated in file 'in2', also outputting unmatched lines from 'in2' - both files must be sorted, and the output format of each line will be: first field of in1, second field of in2, and third field of in2.
join -t, -o 1.1,1.2,2.3 -a1 in1 in2
Make directory "/etc/cron.5minute"
mkdir /etc/cron.5minute
Sort "some_data" by the first and second ";" delimited entries, outputing unique lines and stabilizing the sort
sort -k1,1 -k2,2 -t';' --stable --unique some_data
List all files from the current directory tree that were modified less than 60 minutes ago
find . -mmin -60 | xargs -r ls -l
Remove all vmware-*.log files under current directory
find . -name "vmware-*.log" -exec rm '{}' \;
Append the current date in '%Y%m%d_%H%M' format with the basename of $0 and save it to variable 'LOGNAME'
LOGNAME="`basename "$0"`_`date "+%Y%m%d_%H%M"`"
Find a size of only the target directory in MB format
du -s --block-size=M /path/to/your/directory/
find for lighttpd in /var
find /var -name lighttpd
Find all files/directories named 'query' under current directory
find -name "query"
change the permission of all the normal/regular files to 644 in the current folder
find -type f -exec chmod 644 {} \;
Split "file.txt" into files of at most 20 lines each with a prefix "new"
split -l 20 file.txt new
Copy the current directory tree to '/path/to/destination/dir' preserving permissions, timestamp and ownership
find . | cpio -pdumv /path/to/destination/dir
Set permissions to 700 for directories under media/
find media/ -type d -exec chmod 700 {} \;
display all the symbolic links in the current folder
find . -type l
Print equal lines in compressed files "number.txt" and "xxx.txt"
comm -12 <(zcat number.txt.gz) <(zcat xxx.txt.gz)
Archive "/path/to/copy" on host "remote.host" as user "user" to "/path/to/local/storage" updating files with different checksums, showing human readable progress and statistics, and compressing data during transmission
rsync -chavzP --stats [email protected]:/path/to/copy /path/to/local/storage
List all files in the current directory tree that were modified 60 minutes ago
find . -mmin 60 -print0 | xargs -0r ls -l
find all the files (under root file system /) that were updated in the last 24 hours
find / -mtime -1
find all files read less than 1 minute ago
find . -amin -1
Change the permission to 0644 for all files under current directory
find . -type f -exec chmod 0644 {} \;
List files with C-style escape sequences for non-alphanumeric characters
ls -b
Display differences between /destination/dir/1 and /destination/dir/2 excluding files that match any pattern in file "exclude.pats".
diff /destination/dir/1 /destination/dir/2 -r -X exclude.pats
Find all files/directories in maximum 1 level down the current directory which do not have only read permission for 'other'
find . -maxdepth 1 ! -perm -o=r
Set permissions to 700 for every subdirectory of the current directory
find . -mindepth 1 -type d -print0 | xargs -0 chmod -R 700
Find all files under current directory excluding hidden directories
find -name '.?*' -prune -o \( -type f -print0 \)
Fetch a script from the web and interpert (run) it in the current shell, without writing the script to disk.
source <(wget -q -O - "http://www.modulesgarden.com/manage/dl.php?type=d&id=676")
Print differences between the sorted content of file $1 and file $2, executing 'diff' with options from "${@:3}" array slice
diff "${@:3}" <(sort "$1") <(sort "$2")
Find symbolic links in /usr/sbin and /usr/bin to files whose pathnames end in "*/systemctl"
find /usr/sbin /usr/bin -lname "*/systemctl"
Unsets DUALCASE variable.
unset DUALCASE
Find all syslog directories under /var/log directory
find /var/log -name "syslog" -type d
Split "input.txt" into files of at most 10 bytes each with prefix "xxx/split-file"
split -b 10 input.txt xxx/split-file
find al the tmp directories in the current directory and create a dump of it
find . -type d -name tmp -prune -o -print | cpio -dump /backup
Split a file "file.tar.gz" into pieces named as "file.tar.gz.part-NNN" with size 1024 MB where NNN is a numeric suffix
split -b 1024m "file.tar.gz" "file.tar.gz.part-"
search for the regular/normal file java in the entire file system excluding search in the directories share and those starting with 10_Recommended and discard all the errors
find / \ -prune -o -type f -name java -print 2>/dev/null
Find all directories under /home/me
find /home/me -type d
Find mysong.ogg anywhere under the home directory
find $HOME -name 'mysong.ogg'
Archive "/home/abc/*" to "/mnt/windowsabc" with human readable output
rsync -avh /home/abc/* /mnt/windowsabc
Print process tree, adjusting output width with a screen size.
pstree | cat
Make a directory in the current working directory with a random 32 alphanumeric character name
mkdir $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
find all the files in the current directory which have the size 40 bytes in the current disk partition.
find . -size -40 -xdev -print
Print a sorted list of the extensions of the regular files from the current directory tree
find . -type f | perl -ne 'print $1 if m/\.$/' | sort -u
Archive files in "/mnt/source-tmp" to "/media/destination"
rsync -a /mnt/source-tmp /media/destination/
Find *.pdf files in the PDFs directory tree that contain text "perry sound" and "October 26, 2004"
find PDFs/ -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep -l -Z -i --label="{}" "perry sound" | xargs -0 -I{} grep -i -l --label="{}" "October 26, 2004" "{}"' \;
display all the files ending with .c in the current folder
find . -name \*.c -print0
Recursively copies '../include/gtest' directory to '~/usr/gtest/include/'.
cp -r ../include/gtest ~/usr/gtest/include/
List jobs and their process ids and print them by replacing newline with '^'
joblist=$(jobs -l | tr "\n" "^")
Split standard input into files with at most 75 lines each
split --lines=75
Delete files with inode number 782263 under current directory
find . -inum 782263 -exec rm -i {} \;
Print the names and sizes of all regular files from the current directory tree
find . -type f -printf "%f %s\n"
Archive "/path/to/files/source" to "user@remoteip:/path/to/files/destination" via ssh on port 2121
rsync -azP -e "ssh -p 2121" /path/to/files/source user@remoteip:/path/to/files/destination