nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Run command 'su whoami' on host 'remotehost' | echo "su whoami" |ssh remotehost |
Copy file linked to by "file" to "file" | cp --remove-destination `readlink file` file |
Find and remove multiple files such as *.mp3 or *.txt under current directory | find . -type f -name "*.mp3" -exec rm -f {} \; |
Change all files in "~" which are owned by the group "vboxusers" to be owned by the user group "kent" | find ~ -group vboxusers -exec chown kent:kent {} \; |
Archive "<SOURCE_DIR>" to "[email protected]:/srv/www/prj112/myfolder" | rsync -av <SOURCE_DIR> [email protected]:/srv/www/prj112/myfolder |
unzip and search for a word in all the jar files in the current folder and display the matched file name | find . -iname '*.jar' -printf "unzip -c %p | grep -q '<stringWithOrWithoutSpacesToFind>' && echo %p\n" | sh |
Execute script "your_command_here" for each file from directory tree /target/path passing the filename as an argument to the script | find /target/path -type f -exec your_command_here \{\} \; |
Print the home directory of "$username" | finger $username | awk '/^Directory/ {print $2}' |
Find all files in /var/www/html/zip/data/*/*/*/*/* that are older than 90 days and print only unique parent directory paths | find /var/www/html/zip/data/*/*/*/*/* -type f -mtime +90 -printf "%h\n" | sort | uniq |
Find *.scm files recursively in the current directory | find . -name '*.scm' |
Output all lines in BigFile.csv whose secondn comma-separated second field matches first field of a line in LittleFile.csv. | join -1 2 -2 1 -t, BigFile.csv LittleFile.csv |
Find all files under $musicdir directory | find "$musicdir" -type f -print |
set MyVariable to the value of VARIABLE_NAME | myVariable=$; |
Remove all .txt files in and below the current directory | find . -name "*.txt" -exec rm {} + |
Search the current directory recursively for *.txt files with lines that match regular expression "^string" | find . -name "*.txt" -exec egrep -l '^string' {} \; |
Create a symbolic link named "/usr/bin/my-editor" to "/usr/share/my-editor/my-editor-executable" and attemp to hard link directories | ln -sF /usr/share/my-editor/my-editor-executable /usr/bin/my-editor |
print all files in the current directory and all subdirectories | find . -print |
Split "$file" into files with at most 1000 lines each and use a prefix length of 5 | split -a 5 $file |
Updates 'openssl' package, skipping packages with broken dependencies. | sudo yum update openssl --skip-broken |
Make directory "~/practice" | mkdir ~/practice |
Recursively finds all '*.pdf' files in a current folder and removes them. | find . -name "*.pdf" -exec rm {} \; |
get year-month-day hour:minute:second from date | date +%Y-%m-%d:%H:%M:%S |
Search history for "part_of_the_command_i_still_remember_here" | history | grep 'part_of_the_command_i_still_remember_here' |
Recursively finds all folders in a current folder that contain files like '.git'. | find . -name '.git' | xargs dirname |
Makes 'time' built-in to show only real execution time. | TIMEFORMAT=%R && time ls -l |
Remove blank lines and replace " " with "/" in "struct.txt" as input to make directories with parents as needed | sed '/^$/d;s/ /\//g' struct.txt | xargs mkdir -p |
Print lines 10000 to 10010 from input "seq 1 100000" | seq 1 100000 | sed -n '10000,10010p' |
find all directories named build under the current directory | find . -type d -name build |
Copies all files like "*foo*" under the current directory to the '/your/dest' directory. | find . -name "*foo*" | sed -e "s/'/\\\'/g" -e 's/"/\\"/g' -e 's/ /\\ /g' | xargs cp /your/dest |
Write output of "ls -a" to standard output and to "output.file" | ls -a | tee output.file |
list the details of all the directories in the current folder | find . -type d -exec ls -ld {} \; |
Find all .mp3 files starting from the current directory and delete them | find . -type f -iname *.mp3 -delete |
Query NSS entries for current hostname. | getent `uname -n` |
search for the regular/normal file 'myfile' in the folder /root excluding those that are present in the "work" directory | find /root/ -name 'work' -prune -o -name myfile -type f -print |
Force create a symbolc link named "new_dir" to "/other/dir" without dereferencing "new_dir" | ln -sfn /other/dir new_dir |
Count total number of lines in all files below current directory. | find . -type f -exec wc -l {} \; | awk '{ SUM += $0} END { print SUM }' |
find all the links in the current folder and following it to the pointed path | find -L /target -type l |
forcibly and verbosely create a symbolic link named "target" to file "source" | ln -sfvn source target |
List each file or directory in the current directory prefixed with its filesize in bytes and sorted from smallest to largest | du -s * | sort -n |
Remove all files in and below the current directory whose names begin with "not" | find . -name not\* | xargs -d '\n' rm |
Lists all manual pages. | apropos -r '.*' |
Remove all directories found in directory tree $LOGDIR that were modified more than 5 days ago | find $LOGDIR -type d -mtime +5 -exec rm -f {} \; |
Prefix all files and directories in the current directory with "Unix_" | ls | xargs -I {} mv {} Unix_{} |
Delete all files that were modified more than 60 days ago under '/path-to-directory' tree | find /path-to-directory -mtime +60 -exec rm -f {} \; |
Format output of "mount" as a table | mount | column -t |
Create 6-letter named temporary directory in a folder path that is provided as the first positional parameter, and save the path to it in a variable 'tmp' | tmp=$(mktemp -d $(dirname "$1")/XXXXXX) |
search for all the jpg files in the folder "/mnt/hda1/zdjecia/test1/" and copy these files to the folder /mnt/hda1/test/<same name as the found file> | find /mnt/hda1/zdjecia/test1/ -iname “*.jpg” -type f -exec cp {} -rv /mnt/hda1/test{} ‘;’ |
Print the list of files in directory /tmp/a1 recursively | find /tmp/a1 |
Find all files under 'dir' directory and print their md5 sums into file.txt | find dir -type f | xargs md5sum >> file.txt |
Display summary of each specified file in human readable form | du --summary --human-readable * |
Change permissions to 644 of multiple files with permissions 755 | find . -perm 755 -exec chmod 644 {} \; |
Rename file extension '.andnav' (case insensitive) to '.tile' for all files/directories under current directory tree | find . -name "*.andnav" -exec rename -v 's/\.andnav$/\.tile/i' {} \; |
Remove from the current directory tree all the regular files which have a dot in their names and contain string "<img-name>-<width:integer>x<height:integer>.<file-ext> syntax" | find . -name "*.*" -type f -exec grep -l '<img-name>-<width:integer>x<height:integer>.<file-ext> syntax' {} \; | xargs rm -f |
Print timestamp as HH:MM:SS | date +"%T" |
Keep the last 3 components of $path | echo $path | rev | cut -d'/' -f-3 | rev |
display a long ilsting of all the files in the file system which are bigger than 1KB and which have not been modified in the last 30*24 hours | find / -size +1000 -mtime +30 -exec ls -l {} \; |
Search the current directory tree for files whose names begin with "my" and end with "p" followed by any character | find . -regex ".*/my.*p.$" |
display list of all the hidden directories in the directory "/dir/to/search/" | find /dir/to/search/ -type d -iname ".*" -ls |
Find all files in the current directory tree whose names end with the suffix ".keep.$1", where $1 is the first command line argument, and remove that suffix | find . -type f -name "*.keep.$1" -print0 | xargs -0 rename "s/\.keep\.$1$//" |
Remove trailing white spaces from all *.py files under dir directory and keep backups of the originals | find dir -not -path '.git' -iname '*.py' -print0 | xargs -0 sed --in-place=.bak 's/[[:space:]]*$//'. |
Display kernel name, release, and version. | uname -s -r -v |
Run rsync with options specified by variable OPTS, copying directory specified by variable FIND, and to destination specified by variable BACKUPDIR. | rsync $OPTS $FIND $BACKUPDIR |
search for word linux in all the regular/normal files in the folder mail. | find ~/mail -type f | xargs grep "Linux" |
Find all $tofind* files/directories under $parentdir | find $parentdir -name $tofind* |
Unset RBENV_VERSION variable in global environment. | tmux set-environment -gu RBENV_VERSION |
Verbosely compresses all files on third and fourth depth level keeping original files in place. | bzip2 -kv */*/*/* |
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 files which full path name is /tmp/foo/bar under /tmp/foo directory and print | find /tmp/foo -path /tmp/foo/bar -print |
Find all empty directories in the current one and delete them | find . -type d -maxdepth 1 -empty -delete |
Gets MAC address of 'eth0' network interface. | ifconfig eth0 | grep -Eo ..\(\:..\){5} |
search for all xml files in current folder and display them | find . -name "*.xml" -exec echo {} \; |
Print a count of each unique line in "ip_addresses" | sort ip_addresses | uniq -c |
Find directories in the current directory tree that were modified within the last 24 hours and move them to /path/to/target-dir | find . -depth -type d -mtime 0 -exec mv -t /path/to/target-dir {} + |
Gets string with MAC address of eth0 network interface. | ifconfig eth0 | grep HWaddr |
Locate all files "needle.txt" | find . -name "needle.txt" |
find all files in the current folder which end with macs | find -name '*macs' |
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' {} \; |
Remove files from the home directory tree that were last accessed more than 100 days ago | find ~ -atime +100 -delete |
print all files in the directories except the ./src/emacs directory | find . -wholename './src/emacs' -prune -o -print |
display the contents of all the files in the current folder which start with test (case insensitive search) | find . -iname '*test*' -exec cat {} \; |
Saves logged in users names in 'tmp' variable. | tmp=$(w | awk '{print $1}') |
Run vi with all btree*.c files under current directory | vi $ |
Saves printed calendar of February,1900 in positional variables. | set -- $(cal 2 1900) |
List all crons in the environment | cat /etc/passwd | sed 's/^\:.*$/crontab -u \1 -l 2>\&1/' | grep -v "no crontab for" | sh |
Read a line from standard input and save response in variable "VARNAME" | read VARNAME |
Find all *FooBar* files/directories under current directory and copy them to ~/foo/bar | find -name '*FooBar*' -print0 | xargs -0 cp -t ~/foo/bar |
Search the /path directory tree for files having permissions 777 | find /path -perm ugo+rwx |
Print the first 10 files or directories found in the current directory tree by `find' | find | head |
display all normal/regular files in current folder in sorted order | find . -type f print0 | sort -r |
Back up all *.txt files/directories in new files/directories with a .bak extension in their names under /etc directory | find /etc -print0 -name "*.txt" | xargs -I {} -0 mv {} {}.bak |
Find all sample* files/directories under current directory and print 'program {}-out {}' where {} will expand to file paths | find . -name "sample*" | xargs -i echo program {}-out {} |
Output lines 16224 to 16482 of 'file', and stop reading 'file' after line 16482. | awk 'NR==16224, NR==16482-1; NR==16482 {print; exit}' file |
Find all broken symlinks under /path/to/search directory | find /path/to/search -xtype l |
Show the number of regular files in the current directory tree | find . -type f | wc -l |
Read a single character from standard input into variable "key" without backslash escapes and using the prompt "Press any key to continue..." | read -n1 -r -p "Press any key to continue..." key |
recursively look for files ending in either .py or .py.server | find . -type f -regex ".*\.\(py\|py\.server\)" |
Silently read a line from standard input into variable "REPLY" without backslash escapes and using the prompt $'Press enter to continue...\n' | read -rsp $'Press enter to continue...\n' |
Print and recursively remove the alphabetically last directory in the current directory | find -mindepth 1 -maxdepth 1 -type d | cut -c 3- | sort -k1n | tail -n 1 | xargs -r echo rm -r |
Search the /media/shared directory recursively for MP3 and OGG files | find /media/shared \( -iname "*.mp3" -o -iname "*.ogg" \) |
Print unique lines of sorted file "second.txt" compared to sorted file "first.txt" | comm -13 first.txt second.txt |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.