nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Print all file/directory names without white space safety under the /proc directory | find /proc | xargs |
Print "new.txt" with line numbers prepended and line 2 or any line containing "2" deleted | cat new.txt | nl | sed "/2/d" |
Print URL "http://www.blabla.bla/forum-detail/?ft=72260&fid=34&&pgr=" followed by a number ranging from 1 to 786 | yes 'http://www.blabla.bla/forum-detail/?ft=72260&fid=34&&pgr=' | nl -ba | sed 786q | grep . | awk '{print $2$1}' |
Search for files bigger than 10M | find ~ -size +10M |
Returns the single most recent file in a directory and all subdirectories. | find $DIR -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr | cut -d: -f2- | head -n 1 |
Save the list of files in the current directory tree whose names contain "2011" to /tmp/allfiles | find . -name '*2011*' -print0 > /tmp/allfiles |
Print a sorted list of the extensions of the regular files from the current directory tree | find . -type f | sed -e 's/.*\.//' | sed -e 's/.*\///' | sort -u |
find StringBuffer in all *.java files | find . -type f -name "*.java" -exec grep -l StringBuffer {} \; |
Find all files in the current directory recursively with "linkin park" in their names and copy them to /Users/tommye/Desktop/LP, preserving path hierarchy | find . -type f -iname "*linkin park*" | cpio -pvdmu /Users/tommye/Desktop/LP |
Display current running kernel's compile-time config file. | cat /boot/config-`uname -r` |
find all the symbolic links in the current folder and follow to the pointing file | find -L |
delete all the files ending with "~" in current folder | find -name '*~' -print0 | xargs -0 rm |
Search the system for the file 'myfile' ignoring permission denied errors | find . -name myfile |& grep -v 'Permission denied' |
Print the calendar for February 1956 | cal 02 1956 |
Print IP addresses of the host name | hostname -I | cut -d' ' -f1 |
Show all previously typed shell commands, waiting for user interaction after each page of output. | history | more |
find and image in current folder | find . -iname "Articles.jpg" |
Print disk of mount point "/pa/th" | mount | awk '$3 == "/pa/th" {print $1}' |
Add "Line of text here" on top of each *.py files under current directory | find . -name \*.py | xargs sed -i '1a Line of text here' |
Find all the files on the system that have been modified within the last hour | find / -mmin -60 |
Search for " 000" in the hex dump of "file-with-nulls" | od file-with-nulls | grep ' 000' |
Print the sorted uniqe list of folders in compressed archive nginx-1.0.0.tar.gz | tar tf nginx-1.0.0.tar.gz | xargs dirname | sort | uniq |
Change permissions to u=rw,g=r,o= for all files inside the current directory tree | find . -type f -exec chmod u=rw,g=r,o= '{}' \; |
Find all *.ini files | find . -name *.ini |
Find all *fstab* files under and below /etc | find /etc -name *fstab* |
Save the number of matching executables for "$cmd" in $PATH to variable "candidates" | candidates=$(which -a $cmd | wc -l) |
run command 'bash --rcfile <' as user root with a bash shell | su -s /bin/bash -c 'bash --rcfile <' |
Print IP addresses of the host name | hostname --ip-address |
Change user ownership to `foo' for files with UID=1005 | find / -user 1005 -exec chown -h foo {} \; |
Download "http://archive.ubuntu.com/ubuntu/pool/universe/s/splint/splint_3.1.2.dfsg1-2.diff.gz", unzip it, and view the output in "less" | curl -s 'http://archive.ubuntu.com/ubuntu/pool/universe/s/splint/splint_3.1.2.dfsg1-2.diff.gz' | gunzip -dc | less |
Delete all files in the /myDir directory tree that were last modified 7 days ago | find /myDir -mtime 7 -exec rm -rf {} \; |
Find all files/directories that are owned by user 'eric' under current directory tree | find -user eric -print |
Change directory to parent directory and do not resolve any symlinks in the resulting path | cd -L .. |
Print command line of process with pid 17709 | cat /proc/17709/cmdline | xargs -0 echo |
Rename all "thumbs" directories to "thumb" in the current directory tree | find . -type d | awk -F'/' '{print NF, $0}' | sort -k 1 -n -r | awk '{print $2}' | sed 'p;s/\(.*\)thumbs/\1thumb/' | xargs -n2 mv |
Delete all but the most recent 5 files | ls -tr | head -n -5 | xargs rm |
list all javascipts file which whole name does not contain excludeddir or excludedir2 or excludedir3 | find . -name '*.js' | grep -v excludeddir | grep -v excludedir2 | grep -v excludedir3 |
Set up local port forwards in the background with no terminal or command execution from port 4431 to host "www1" port 443 and port 4432 to host "www2" port 443 via the host "colocatedserver" | ssh -fNT -L4431:www1:443 -L4432:www2:443 colocatedserver |
Search the current directory tree for regular files that contain "string" | find . -type f -printf '"%p"\n' | xargs grep string |
list *.bmp and *.txt files under the /home/user/Desktop directory. | find /home/user/Desktop -name '*.bmp' -o -name '*.txt' |
Use ANSI escape codes to make "World" bold from input "Hello World!" | echo 'Hello World!' | sed $'s/World/\e[1m&\e[0m/' |
Make directories to "/my/other/path/here" as needed | mkdir -p /my/other/path/here |
Search .c and .h files in the current directory tree for "expr" | find . -name '*.[ch]' | xargs grep -E 'expr' |
Print the IP addresses for the current host name | hostname -I | awk -F" " '{print $1}' |
Find all regular files in the current directory tree and search them for "example" | find -type f -print0 | xargs -r0 grep -F 'example' |
find all the links in the current directory and print them in each line and display their names. | find . -type l -print | xargs ls -ld | awk '{print $10}' |
find all gif files in the file system | find / -name "*gif" -print |
find all the files in current directory of size smaller than 10KB. | find . -size -10k |
find all the files in the current directory which have been modified in the last 6 days. | find . -atime +6 |
create and list filenames in the archive | tar cf - $PWD|tar tvf -|awk '{print $6}'|grep -v "/$" |
Finds all files having text "texthere" recursively in a current folder, and precedes found string with string number in file and file name. | find -type f -exec grep -Hn "texthere" {} + |
Prints local machine's LAN IP address | ifconfig `ip route | grep default | head -1 | sed 's/\\\/\2/g'` | grep -oE "\b{3}[0-9]{1,3}\b" | head -1 |
Create links for all files in the current directory tree that are more than 1000 days old in "/home/user/archives" | find . -type f -mtime +1000 -print0 | cpio -dumpl0 /home/user/archives |
Replace " " with " $UID " in the output of "history" | history | sed "s/ / $UID /" |
Find regular files in the current directory tree that have executable bits set for the user and group but not for the other | find -L . -type f -perm -u=x,g=x \! -perm -o=x |
Read standard input until a null character is found and save the result in variable "line" | read -r -d $'\0' |
Report file systems disk usage human-readable using POSIX output format. | df -Ph |
List all files in current directory whose name or file type description contains the word "ASCII". | file * | grep ASCII |
Search for all files newer than file /tmp/t1 but not newer than file /tmp/t2 | find / -newer /tmp/t1 -and -not -newer /tmp/t2 |
find suffix tcl files under all directories started with 'n' | find ./n* -name "*.tcl" |
Remove a leading "machine" from the system host name and save the result to variable "machnum" | machnum=$(hostname | sed 's/^machine//') |
Print the path of all the network mounts | mount | sed -n -e "s/\/\/mynetaddr on \([^ ]*\).*$/\1/p" |
display all instances of the .profile file in the entire file system | find / -name .profile -print |
Find a directory named 'project.images' in the entire filesystem and show it in long listing format | find / -type d -name "project.images" -ls |
display all the files in the current folder which have are bigger than 1KB | find . -size +1024 -print |
rename all the png files to jpg files in the current fodler | find . -name "*.png" -print0 | sed 'p;s/\.png/\.jpg/' | xargs -0 -n2 mv |
Print the 6th field (delimited by '/') from the paths specified by ~/bin/FilesDvorak/.* files/directories | find ~/bin/FilesDvorak/.* -maxdepth 0 | awk -F"/" '{ print $6 }' |
Remount "/" with read and write permission | mount / -o remount,rw |
display a long listing of all the files in the current folder in sorted order, which are bigger than 10KB | find . -size +10k -exec ls -ls {} \+ | sort -nr |
Change permissions of all directories residing under and below ./debian to 755 | find ./debian -type d | xargs chmod 755 |
Find all files in /dir1 and print only the filenames | find /dir1 -type f -printf "%f\n" |
Wrap each line in "file.txt" to fit in 80 characters | fold -w 80 file.txt |
Pushes current folder to the directory stack. | pushd $PWD |
The command runs all the directories found in the $LOGDIR directory wherein a file's data has been modified within the last 24 hours and compresses them to save disk space. | find $LOGDIR -type d -mtime +0 -exec compress -r {} \; |
Find regular files modified within the last ten minutes under /etc | find /etc -type f -mmin -10 |
Read lookup requests from text file '1.txt' and uses them to fetch TXT records. | dig TXT -f 1.txt |
Print the contents of all file* files under current directory with white space safety in file names | find . -name "file*" -print0 | xargs -0 perl -ple '' |
Numerically sort file "files" by the second "-" separated value of each line ordered from least value to highest value | tac files | sort -t- -k2,2 -n |
Print the list of files in the current directory tree skipping SVN files | find . -name .svn -a -type d -prune -o -print |
Find all files/directories under current directory tree that contain 'pattern' in their names | find -name "*pattern*" |
Copies all files like "*FooBar*" under the current directory to the '~/foo/bar' directory. | find . -name '*FoooBar*' | sed 's/.*/"&"/' | xargs cp ~/foo/bar |
change permission of all the files in the entire file system which have permissions 777. | find / -type f -perm 0777 -print -exec chmod 644 {} \; |
search all jpg,png,jpefg files in the current folder and calculate the total size of them | find . \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) -ls | awk '{total += $7} END {print total}' |
find all the files in the file system which have been changed 1 minute ago. | find / -newerct '1 minute ago' -print |
Recursively changes group ownership of the $PATH_TO_OUTPUT_FOLDER directory to $GROUP group. | chgrp -R $GROUP $PATH_TO_OUTPUT_FOLDER |
Run the command 'true' with an empty environment variable doFirst | doFirst="" true |
Search all .py files in the current directory tree for "some_function" | find . -name \*.py | xargs grep some_function |
display all the files in the current folder which have been modified after the files "/bin/sh" | find . -newer /bin/sh |
Make directories to "/tmp/boostinst" as needed and print a message for each created directory | mkdir -pv /tmp/boostinst |
Removes all files from current folder but 5 newest ones. | find . -maxdepth 1 -type f -printf '%T@ %p\0' | sort -r -z -n | awk 'BEGIN { RS="\0"; ORS="\0"; FS="" } NR > 5 { sub("^[0-9]*? ", ""); print }' | xargs -0 rm -f |
Find all *.c files under and below the current directory that contain "wait_event_interruptible" | find . -name \*.c -print0 | xargs -0 grep wait_event_interruptible /dev/null |
Find files/directories in entire file system that were modified a day ago | find / -mtime 1 |
Keep only the last two hyphen-separated sections of "abc-def-ghi-jkl" | echo "abc-def-ghi-jkl" | rev | cut -d- -f-2 | rev |
Count the number of open files for PID "$PYTHONPID" every 2 seconds | watch "ls /proc/$PYTHONPID/fd | wc -l" |
Preprocess C++ file 'omnitest.cpp' and page interactively through the result. | g++ omnitest.cpp -E | less |
Delete all shared memory and semaphores for the current user on linux | ipcs -a | nawk -v u=`whoami` '$5==u &&(||){print "ipcrm -"$1,$2,";"}' | /bin/sh |
Search for all .html files in directory "www" and output only the basename (without containing path) of each. | find www -name \*.html -type f -exec basename {} \; |
find .gif files in /var/www and below that were last changed between 90 and 180 days ago | find /var/www -name *.gif -ctime +90 -ctime -180 |
Find all files owned by user `comp' | find / -user comp |
Display differences between directories dir1 and dir2. | diff -r dir1 dir2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.