nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Sorts content of the $tmp file and filters out all strings with ':0'.
sort $tmp | grep -v ':0' #... handle as required
Remove all "core" regular files in the /tmp/ directory tree
find /tmp -name core -type f -print | xargs /bin/rm -f
find all files that names are 'apt' and display detailed list
find / -name "apt" -ls
Remove trailing white spaces from all files under current directory ignoring .git and .svn directories
find . -not \( -name .svn -prune -o -name .git -prune \) -type f -exec sed -i "s/[[:space:]]*$//g" "{}" \;
Find all the SGID bit files whose permissions set to 644 in the file system
find / -perm 2644
List all files and sub directories including hidden files in the current directory tree
tree -af
grep for the last occurrence of text between two tags
tac a | grep -m1 -oP '.*'
display the name and size of all the regular/normal files in the var/log folder which are bigger than 100MB
find /var/log -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
find all the text files in the home folder and display the first lines. Save the output to the file report.txt
find $HOME/. -name *.txt -exec head -n 1 -v {} \; > report.txt
find all *.java files/directories under current directory
find . -name "*.java"
Look for *log files in directories at least three levels down the directory tree
find / -mindepth 3 -name "*log"
force remove all the directories with the name logs in the folder /var/www
find /var/www -type d -mtime 0 -name logs -exec sudo rm -fr {} \;
Find all *.pdf files under ./polkadots
find ./polkadots -type f -name "*.pdf"
Look for *.jpg files on the system
find / -name “*.jpg”
Write output and error of "ant" to the console and to "build.log"
ant 2>&1|tee build.log
Convert relative path "/x/y/../../a/b/z/../c/d" into absolute path with resolved symbolic links
readlink -f /x/y/../../a/b/z/../c/d
Find all SUID files .
find / -perm /u=s
split the file 2011.psv into pieces per 50000000 lines processed with script "filter.sh"
split -l 50000000 --filter=./filter.sh 2011.psv
Print ls output for all non-empty files under under current directory
find . -type f ! -size 0 -exec ls -l '{}' \;
Search the regular files of the current directory tree for string "whatever"
find . -type f | xargs grep whatever
Saves printed calendar of February,1900 in positional variables.
set -- $
List all files/directories under current directory using comma as the delimiter for different fields in the output
find . -ls | awk '{printf}'
Print the first line of every file matching pattern 'file?B' in the xargstest/ directory tree
find xargstest/ -name 'file?B' | sort | xargs head -n1
Search for .pdf files
find / -name '*.pdf'
Find all regular files that reside in the current directory tree and were last modified at least 1 day ago
find . -type f -mtime +0
Print file type of the executable file of command "python"
file `which python`
Search all the regular files from the current directory tree for "search string"
find . -type f -print -exec grep --color=auto --no-messages -nH "search string" "{}" \;
Find regular files whose names end in .JPG
find . -type f -name "*.JPG"
Backup permissions of the files in the current directory tree
find -depth -printf '%m:%u:%g:%p\0' >saved-permissions
Find absolute path of command with PID "$pid"
readlink -f `ls --dereference /proc/$pid/exe`
Print all lines of "seq 1 10" except the last 3
seq 1 10 | perl -ne 'print if ' | perl -ne 'print if ' | perl -ne 'print if '
Check if a drive with UUID "09b8f1ab-8d4b-4c5f-b395-40be09c090b0" is mounted on "/media/WD_Disk_1"
mount | grep $ | grep '/media/WD_Disk_1 '
print all files in the current directory and all subdirectories
find . -print
Search for symlinks pointing to anywhere within /mnt/oldname/
find / -type l -lname '/mnt/oldname*'
List all files and directories from the current directory tree
find . -print | xargs ls
Search all *.txt files under ~/documents for the word "DOGS"
find ~/documents -type f -name '*.txt' -exec grep -s DOGS {} \; -print
Delete all files that have not been accessed in the last 30 days
find . -type f -atime +30 -exec rm {} \;
display all the jpg images in current folder
find . -type f -iregex '.*\.jpe?g'
Search for 'foo' in all the java files under 'dir1', 'dir2' and 'dir3' directory tree and print only the names of the matched files
find dir1 dir2 dir3 -type f -name "*.java" -exec grep -il 'foo' {} \;
search for all the c files in the current folder
find . -name \*.c -print
Read a single character from standard input with delimeter '' and no echo
read -d'' -s -n1
Search the current directory recursively for files containing "needle text"
find . -type f -exec grep -Iq . {} \; -and -print0 | xargs -0 grep "needle text"
Find 10 most recently changed files in the current directory tree
find . -type f -printf "%C@ %p\n" | sort -rn | head -n 10
Find links to any file that happens to be named `foo.txt'
find / -lname foo.txt
Split the contents of all ".txt" excluding the first 1000 lines into files of at most 1000 lines each
cat *.txt | tail -n +1001 | split --lines=1000
Search for the string 'foo' in *.html files under /usr/src/linux directory
grep foo `find /usr/src/linux -name "*.html"`
show all directories in the current folder excluding those that are present in the sub directories of media, images and backups
find . -type d \( -name media -o -name images -o -name backups \) -prune -o -print
Find all the files without permission 777 in the file system
find / -type f ! -perm 777
Search the *.cc files in the current directory tree for string "xxx"
find . -name "*.cc" -print -exec grep "xxx" {} \;
Compress from standard input with gzip
gzip
Set LANG variable to 'en_US' and prints calendar for a current month.
LANG=en_US cal
Create a copy of index.html in all directories in current directory, pausing for confirmation before overwriting any existing files - names may not contain spaces - names may not contain spaces.
find . -mindepth 1 -maxdepth 1 -type d| xargs -n 1 cp -i index.html
Remove the line matching "pattern to match" in "./infile" and print to standard output
sed '/pattern to match/d' ./infile
Download 10 web pages "http://example.com/?page${i}.html" at most 2 at a time with "${i}" ranging from 1 to 10
seq 1 10 | xargs -n1 -P2 bash -c 'i=$0; url="http://example.com/?page${i}.html"; curl -O -s $url'
Search the current directory tree for files and directories called "test"
find . -name test -print
Report file system containing path to the current working directory disk usage human-readable.
df -h .
change the group of all regular/normal files in the current directory
find . -type f -exec chgrp usergroup {} \;
List all nfs mount points on the system
mount -l | grep 'type nfs' | sed 's/.* on \([^ ]*\) .*/\1/'
Prints total number of lines of all *.c files in a current folder and subfolders.
find . -name '*.c' -print0 |xargs -0 wc -l|grep -v total|awk '{ sum += $1; } END { print "SUM: " sum; }'
Print lines in "file1.txt" that do not exist in "file2.txt"
sort < file2.txt file2.txt | uniq -u
Replace all commas with tab characters in 'filename.csv' and page interactively through the result.
sed "s/,/\t/g" filename.csv | less
Find all regular files that reside in the current directory tree and were last modified more than 3 days ago
find . -type f -mtime +3
Continuously write "Hidden" separated by spaces over the entire "/dev/sdb" disk
yes "Hidden" | paste -d' ' -s - | dd of=/dev/sdb
Compress every file in the current directory tree that matches "*cache.html" and keep the original file
find . -type f -name "*cache.html" -exec gzip -k {} \;
Find all files in current directory that were modified less than 1 day ago excluding hidden files and put the output to full_backup_dir variable
full_backup_dir=$(find . -depth \( -wholename \./\.\* \) -prune -o -mtime -1 -print)
find all the files ending with "mkv" in current folder
find -name "*.mkv"
Print info about thread number of process with pid 1
cat /proc/1/sched | head -n 1
Find all directories in the current one with "linkin park" in their names and copy them to /Users/tommye/Desktop/LP
find . -maxdepth 1 -type d -iname "*linkin park*" -exec cp -r {} /Users/tommye/Desktop/LP \;
find all files in current folder which are bigger than 1MB
find ./ -size +1000k
Search the current directory recursively for files containing "needle text"
find . -type f | xargs grep -I "needle text"
Count all directories in maximum 1 level down the current directory
find . -maxdepth 1 -type d -exec ls -dlrt {} \; | wc --lines
Remove all vmware-*.log files under current directory
find . -name vmware-*.log | xargs rm
Compress from standard input and print the byte count preceded with 'gzip.'
echo gzip. $( gzip | wc -c )
Find symlinks in the current directory tree
find . -type l | xargs ls -ld
Compress every file in the current directory tree that matches "*cache.html" and keep the original file
find . -type f -name "*cache.html" -exec gzip -k {} \;
List directories in the current working directory and remove the trailing "/"
ls -d */|sed 's|[/]||g'
Unzip all files matching "/homes/ndeklein/mzml/*.gz"
ls /homes/ndeklein/mzml/*.gz | xargs -I {} gunzip {}
Extracts single file 'filename' from bzip2-compressed tarball archive.tbz.
bzip2 -dc archive.tbz | tar xvf - filename
Find all files/directories under current directory that are 10MB in size
find . -size 10M
find all the files in the entire filesystem which belong to the user root and display the ten files.
find / -user root | head
find all regular/normal files in the current folder that have been modified in the last 120 hours
find -mtime -5 -type f -print
Lists tmux sessions.
tmux list-sessions
Lists all files in a current folder, separating names with comma.
ls -m
find all the files that have not been modified in the last 24 hours
find /tmp/test/* -mtime +1
find regular files which modification time is 7 days ago
find . -mtime -7 -type f
Search for directory foo ignoring case
find . -iname foo -type d
Print numbers 1 through 10 separated by ":"
yes | head -n10 | grep -n . | cut -d: -f1 | paste -sd:
Find all files and directories that have been modified in the last seven days.
find . -mtime -7
Finds all folders that contain 'ssh' file and have 'bin' in path.
dirname `find / -name ssh | grep bin`
Find all files in current directory that were modified less than 1 day ago excluding hidden files and archive them and put the output into the variable file_changed
file_changed=$(find . -depth \ -prune -o -mtime -1 -print | cpio -oav)
Get the list of regular files in the current directory
find . -mindepth 1 -maxdepth 1 -type f -print0 | xargs -0 -I {} echo "{}"
find all the files in the current folder and display them in the sorted order of their name
find . | sort
Continuously send "y" to input of "command"
yes | command
Prints sequentially listing of a current folder and calendar of a current month.
echo `ls` "`cal`"
delete all the normal files in the current directory whcih have the word "gui" in their content.
find / -type f -print0 | xargs -0 grep -liwZ GUI | xargs -0 rm -f
Enables shell option 'cdable_vars'.
shopt -s cdable_vars
Change the group to `temp' for all files in the current directory tree that belong to group `root'
find . -group root -print | xargs chgrp temp
display all files in current folder ending with "~" or "#" using regular expression
find -regex "^.*~$\|^.*#$"
Forward all connections to client localhost 3309 via the SSH tunnel to "mysql_access_server" and then connect to host "sqlmaster.example.com" on port 3306
ssh -f mysql_access_server -L 3309:sqlmaster.example.com:3306 -N
forcibly create a symbolic link named "linkname" to file "new_destination"
ln -sf new_destination linkname