nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Format file "list-of-entries.txt" with no column delimiter | column -t -s '' list-of-entries.txt |
Find all files under /somefolder matching the case insensitive regex '\\|\\|\' in their paths | find /somefolder -type f | grep -i '\\|\\|\' |
Find all php files whose name is tecmint.php in a current working directory | find . -type f -name tecmint.php |
Print which files differ in "dir1" and "dir2" recursively | diff -rq dir1 dir2 |
display all the files in the home folder except text files | find /home ! -name "*.txt" |
display all the files in the folders mydir1, mydir2 which are bigger than 2KB and have not been accessed in the last 30*24 hours | find /mydir1 /mydir2 -size +2000 -atime +30 -print |
find all text files in user/directory/ and display the last line | find /user/directory/* -name "*txt" -mtime 0 -type f -exec awk '{s=$0};END{print FILENAME, ": ",s}' {} \; |
prints top 10 processes sorted by memory usage | ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 10 |
Truncate all regular files under the current directory | find . -type f -maxdepth 1 -print0 | xargs -0i sh -c "cat /dev/null > \"{}\"" |
find all html files in the current directory which have size greater than 100 bytes and display their details and discard all the errors. | find . \ -name '*.html' \ -exec ls -l {} \; 2> /dev/null |
Request that the master ssh connection "otherHosttunnel" exits | ssh -O exit otherHosttunnel |
Search for files that are at least 100MB | find / -size +100M |
Find every file under the directory /var/spool that was modified more than 60 days ago. | find /var/spool -mtime +60 |
Split "$FILENAME" into files with at most 20 lines each with a prefix "xyz" | split -l 20 $FILENAME xyz |
Remove all a.out, *.o, and core files under the current directory | find . \( -name a.out -o -name '*.o' -o -name 'core' \) -exec rm {} \; |
Find all files named 'file' in 1 level down the current directory whose status were changed more than 1 hour ago and redirect the ouput to /tmp.$$ | find . -maxdepth 1 -cmin +60 -name file >/tmp.$$ |
list in long format all files from / whose filename ends in "jbd", not descending into directories that are not readable while searching, and not descending into directories on other filesystems | find / -mount \! -readable -prune -o -path /dev -prune -o -name '*.jbd' -ls |
Find all files/directories that start with 'screen' (case insensitive) in their names under user's home directory tree and show them by paging through one screenful at a time | find ~ -iname "screen*" | more |
find all the hidden files in the temp folder | find /tmp -type f -name ".*" |
Archive "./htmlguide" to "~/src/" with resolved symbolic links and delete any extraneous files from "~/src/" not found in "./htmlguide" | rsync -av --copy-dirlinks --delete ../htmlguide ~/src/ |
Display only first and second dot-separated numbers of kernel version, ie. 4.4 | uname -r | sed 's/\\..*/\1/' |
search for perl files in the folder /users/tom | find /users/tom -name "*.pl" |
find files in root directory that names are game | find / -name game |
display all files in current folder using regular expression | find -regex "$rx" |
Search for files/directories with the case insensitive pattern anaconda.* in var/log directory | find var/log/ -iname anaconda.* |
Find all files/directories under current directory with 'FooBar' in their paths and copy them to ~/foo/bar | find .|grep "FooBar"|xargs -I{} cp "{}" ~/foo/bar |
Find all files in the current directory tree except .html, ignoring .svn directories | find . \( -type d -name '.svn' -o -type f -name '*.html' \) -prune -o -print0 |
Search the /storage/sdcard0/tencent/MicroMsg/ directory tree for JPG files | find /storage/sdcard0/tencent/MicroMsg/ -type f -iname '*.jpg' -print0 |
Get second line from text contained in variable $data. | echo "$data" | cut -f2 -d$'\n' |
display long list of all the perl files in the current folder | find . -name "*.pl" -ls |
Find all files in $dir directory without going into sub-directories and print only their names preceded by 3 spaces | find "$dir" -maxdepth 1 -type f | sed 's#.*/# #' |
delete recursively, without prompting, any files or directories under the current directory that case insensitively match the filename ".svn" | find . -iname .svn -print | xargs rm -rf |
find all the perl files in the current folder, print0 is used to handle files with new lines in their names or only spaces | find . -type f -name "*.pl" -print0 |
Search all regular files in the current directory tree for "string" | find . -type f -exec grep string {} \; |
Remove trailing white spaces from all files under dir directory ensuring white space safety in the filename | find dir -type f -print0 | xargs -r0 sed -i 's/ *$//' |
Give a long listing of all the *.pl files (Perl files) beneath the current directory. | find . -name "*.pl" -exec ls -ld {} \; |
Print joined strings from 'file', using space symbol as separator. | cat file | xargs |
display the number of lines in all the ".c" files in the current folder | find . -name "*.c" -print0 | xargs -0 wc -l |
Search for regular files of the user bluher in the file system | find / -type f -user bluher -exec ls -ls {} \; |
show all files in the current directory and all subdirectories | find . -print |
Show IPC information owned by the current user | ipcs -a | grep `whoami` |
delete all the ".doc" files in the current folder | find . -name '*.doc' -exec rm "{}" \; |
set alias "py" for command "python2.5 -O" | alias py='python2.5 -O' |
Find all directories in level 1 down the $queue directory | echo "$queue" | xargs -I'{}' find {} -mindepth 1 -maxdepth 1 -type d |
delete all the trace files which have not been been accessed in the last 30*24 hours | find /dirpath \ -exec rm {} \; |
Print a single line of numbers from "001" to "100" | yes | head -n 100 | awk '{printf( "%03d ", NR )}' |
Saves folder path where target of symbolic link $file file is located in 'base' variable. | base=$(dirname $) |
Save all directories under the current directory as a comma separated list in variable "FOLDERS" | FOLDERS=$ |
Join columns in "file1" and "file2" if their first field matches and format the output as a table | awk 'NR==FNR{m[$1]=$2" "$3; next} {print $0, m[$1]}' file2 file1 | column -t |
Extracts a bz2 file. | bunzip2 file.bz2 |
Search the given $directory for files with permissions stored in $permissions | find "$directory" -perm "$permissions" |
Find all of the character devices on the system | find / -type c |
find all files and directories that have been modified in the last seven days | find . -mtime -7 |
Insert "insert" every 3 lines for the output of "seq 1 10" | seq 1 10 | sed $': loop; n; n; a insert\nn; b loop' |
find files in current folder using name patterns and sort the display the file names in the sorted order | find . -name "S1A*1S*SAFE" | awk -F/ '{print $NF"/"$0}' | sort -t_ -k 5,5 | cut -d/ -f 2- |
Find all regular files with case insensitive pattern '*$1*' ($1 expands to first positional parameter and falls back to empty string when not given) under current directory tree and execute a command given by $2 (falls back to 'file' command when $2 is not given) with each of those files as arguments | find . -type f -iname '*'"${1:-}"'*' -exec ${2:-file} {} \; |
Remove the regular files from the current directory tree that were last modified on November, 21 | find -type f -newermt "Nov 21" ! -newermt "Nov 22" -delete |
Copy all *.txt files from the current directory tree to /destination | find . -name '*.txt' | while IFS= read -r FILE; do echo "Copying $FILE.."; cp "$FILE" /destination; done |
Places current job to background. | bg % so it wont die when you logoff |
Search the current directory tree for *.c and *.sh files | find . -type f \ |
list all javascipts file which whole name does not contain "directory" | find . -name '*.js' -and -not -path directory |
Prints full path to files in a current folder. | ls -1 | awk -vpath=$PWD/ '{print path$1}' |
Print login name and full name of all users currently logged in | finger -l | awk '/^Login/' |
Find all empty files under a certain path | find /tmp -type f -empty |
Moves the file that named like file $1 from '/tmp' folder to the folder where $2 file is located. | mv "/tmp/`basename $1`" "`dirname $2`" |
Save first one of space separated parts of each line in $LOCKFILE file to the 'CURRENT_PID_FROM_LOCKFILE' variable | CURRENT_PID_FROM_LOCKFILE=`cat $LOCKFILE | cut -f 1 -d " "` |
Reports count of characters in the value of ${FOO_NO_TRAIL_SPACE} variable as follows: "length==<counted number of characters>" | echo -e "length==$" |
Print canonical filename of "/path/here/.." | readlink -f /path/here/.. |
Find all directories under current directory and set their permission to 775 | find -type d | xargs chmod 775 |
Wrap each line in "file.txt" to fit in 80 characters | cat file.txt | fold |
Split "file.txt" excluding the first line into files with at most 20 lines each and a prefix "split_" | tail -n +2 file.txt | split -l 20 - split_ |
Find all .java files whose name contains "Message" | find . -print | grep '.*Message.*\.java' |
Find all MP3s in the /home directory tree | find /home -type f -name '*.mp3' |
Get domain name of $ip and save it to the variable 'reverse' | reverse=$ |
List all functions or variables containing " ()" defined in the shell | set | grep " ()" |
Print the byte count of all regular files found in the current directory tree | find . -type f | xargs | wc -c |
Write "hey hey, we're the monkees" to standard output and as input to "gzip --stdout > my_log.gz" | echo "hey hey, we're the monkees" | tee > |
Send SIGTERM to all processes using TCP port 6000 on the system. | kill -15 $ |
List all empty files under the current directory | find . -maxdepth 1 -empty |
Display a count of regular files in each directory at the current level. | find -P . -type f | rev | cut -d/ -f2- | rev | cut -d/ -f1-2 | cut -d/ -f2- | sort | uniq -c |
Find all files under dir and calculate their md5sum and save the output to dir.md5 | find dir -type f -print0 | xargs -0 md5sum > dir.md5 |
Search the current directory recursively for regular files last modified more than 2 days ago | find . type -f -mtime +2 |
find dirctory files which modification time is 7 days ago | find . -mtime -7 -type d |
Find all the files/directories under '/usr/local' directory tree which have been modified within the last day | find /usr/local -mtime -1 |
Recursively copies "$appname.app", preserving symlinks as symlinks to the 'Payload' directory. | cp -Rp "$appname.app" Payload/ |
Copy the directory structure in "src/" to "dest/" with empty files | find src/ -type d -exec mkdir -p dest/{} \; -o -type f -exec touch dest/{} \; |
Find all files/directories under current /export/home/someone directory and upload them to ftp://somehost/tmp/ | find /export/home/someone -exec curl -u someone:password -vT {} ftp://somehost/tmp/ |
Find all *.sql file that are not newer than $oldest_to_keep excluding the $oldest_to_keep file | find . -name \*.sql -not -samefile $oldest_to_keep -not -newer $oldest_to_keep |
Send SIGHUP signal to all SSH server processes, causing them to re-read the SSH server configuration. | kill -HUP $ |
Move "tobecopied/tobeexclude" to "tobeexclude" | mv tobecopied/tobeexclude tobeexclude; |
Print a list of all *.code files from the current directory tree | find . -name *.code |
Print each logged in user's full name | finger -l | grep "Name:" | cut -d ":" -f 3 | cut -c 2- | sort | uniq |
Installs package group "Development Tools" answering 'yes' on all questions. | yum -y groupinstall "Development Tools" |
Print and delete all directories named 'work' under '/usr/ports/' directory tree | find /usr/ports/ -name work -type d -print -exec rm -rf {} \; |
On host "server_b", connect as ssh user "user" and copy "/my_folder/my_file.xml" to directory "/my_new_folder/". | scp user@server_b:/my_folder/my_file.xml user@server_b:/my_new_folder/ |
Find all regular files with 400 permission under '/data' directory tree | find /data -type f -perm 400 -print |
get the git user access | su git |
Print only common strings in sorted content of files 'file1' and 'file2' | comm -1 -2 <(sort file1) <(sort file2) |
Find all regular files under current directory tree containing 'some text' in their names without descending into hidden directories and excluding hidden files | find . -type d -path '*/\.*' -prune -o -not -name '.*' -type f -name '*some text*' -print |
Remove regular files in the current directory tree | find . -type f -print0 | xargs -0 -n1 echo rm | sh -x |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.