nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
find all readme files in a folder | find /usr/share/doc -name README |
Find all the files that were modified within the last day | find . -mtime -1 |
Request MX record of 'example.com' domain, and filter out all comment strings | dig mx example.com | grep -v '^;' | grep example.com |
Remove all tmp/*.mp3 files | find tmp -maxdepth 1 -name '*.mp3' -maxdepth 1 | xargs rm |
Recursively finds string 'class foo' in all *.c files from current folder. | grep "class foo" **/*.c |
Creates temporary folder in TMPDIR (if defined) or in '/tmp/', and stores path to created folder in 'tmpdir' variable. | tmpdir=$(mktemp -d) |
search a url in all regular/normal files in a folder. | find ./ -type f -exec grep https://www.ksknet.net {} \; |
search for all xml files in current folder and display them | find . -name "*.xml" -exec echo {} \; |
Find empty files/directories under test directory | find test -empty |
Print unique lines of "a" and "b" | comm -3 a b |
find the file "foo.txt" in the current folder and assign the output to a variable | OUTPUT=`find . -name foo.txt` |
Find all empty directories under /tmp | find /tmp -type d -empty |
Report file systems inodes usage. | df -i |
Prints date of first Tuesday in January, 2015 | cal 01 2015 | sed -n '1,2b;/^.\{6\} \{0,1\}\([0-9]\{1,2\}\) .*/ {s//0\1/;s/.*\([0-9]\{2\}\)$/\1/p;q;}' |
Delete all files in the $DIR directory that have not been accessed in 5 or more days. | find "$DIR" -type f -atime +5 -exec rm {} \; |
Find all directories under current directory and set read-write-execute permission for owner, read-execute permission for group and no permission for other for those directories | find . -type d -exec chmod u=rwx,g=rx,o= '{}' \; |
Find all files under foldername directory and set their permission to 644 | sudo find foldername -type f -exec chmod 644 {} ";" |
Write the standard output and error of "ls" to standard output and "/tmp/ls.txt" | ls 2>&1 | tee /tmp/ls.txt |
long list the detials of all the shell scripts in current directory | find . -name "*.sh" -exec ls -ld {} \; |
Print a space separated list of numbers from 1 to 10 | seq 10 | xargs |
display the long listing detials of all the files in the folder junk which is in home folder. | find ~/junk -name "*" -exec ls -l {} \; |
find all the *.conf files under / | find / -name "*.conf" |
print all files which name is xyzzy followed by null and save to list | find / -name xyzzy -print0 > list |
Find files/directories under current directory matching the posix-egrep type regex ".+\.(c|cpp|h)$" in their names | find . -regextype posix-egrep -regex ".+\.(c|cpp|h)$" |
run command "cd /home/$USERNAME/$PROJECT; svn update" with a shell as user username2 | sudo -u username2 -H sh -c "cd /home/$USERNAME/$PROJECT; svn update" |
find all js files which path neither ./dir1 nor ./dir2 | find . -name '*.js' -not \ |
Search for files/directories with the case insensitive pattern anaconda.* in var/log directory and create an archive (somefile.tar) of all the files found ensuring white space safety | find var/log -print0 -iname 'anaconda.*' | tar -cvf somefile.tar -T - |
Recursively change owner and group to "$JBOSS_AS_USER" of "$JBOSS_AS_DIR" | chown -R $JBOSS_AS_USER:$JBOSS_AS_USER $JBOSS_AS_DIR |
List all files/directories under /myfiles directory | find /myfiles -exec ls -l {} ; |
Find absolute path of command with PID "$pid" | readlink -f `ls --dereference /proc/$pid/exe` |
Change symbolic link "$f" into a file | cp --remove-destination $(readlink $f) $f |
Count the total number of lines in all HTML files under /usr/src that contain string "foo" | time find /usr/src -name "*.html" | xargs /usr/bin/grep -l "foo" | wc -l |
Go to directory /cygdrive/c/Program Files /$dollarsign using single quotes to escape special characters, including dollar signs | cd '/cygdrive/c/Program Files /$dollarsign' |
change the owner of all the files in folder /u/netinst to netinst | find /u/netinst -print | xargs chown netinst |
Print every 16 bytes of standard input in groups of two followed by a space | fold -b16 | sed 's/../& /g' |
Put the output of tty into a variable, then searches the output of "who" for TTY with "/dev/" removed and saves it to "WHOLINE" | TTY=$ WHOLINE=$ |
Find all links pointing to /path/to/foo.txt | find . -lname /path/to/foo.txt |
show all the files in the folder /etc which have been modified in the last 24 hours | find /etc -mtime -1 |
Replace all newlines from the contents of "file" except the last with spaces | sed ':a;N;$!ba;s/\n/ /g' file |
Change owner to "bob" and group to "sftponly" of "/home/bob/writable" | sudo chown bob:sftponly /home/bob/writable |
Find all *.txt files that reside under and below /home/wsuNID/ | find /home/wsuNID/ -name "*.txt" |
Search for regular file foo ignoring case | find . -iname foo -type f |
Find all files/directories under current directory and print their paths | find . -exec echo {} ';' |
Find all directories under current directory | find . -type d -print |
Extract path and query part from URL | echo "$url" | cut -d'/' -f4- |
Find all files/directories under current directory with null character as the delimiter | find -print0 |
Set variable "b" to the first word of "a" converted to lowercase. | b=`echo "$a" | awk '{ print tolower($1) }'` |
List all files in entire file system that belong to the user wnj or modified later than the ttt file | find / \( -newer ttt -or -user wnj \) -print |
Run `command' on each file from the current directory tree | find . -exec command {} \; |
Start "xeyes" in the background on the remote server and exit the SSH session | ssh user@server 'DISPLAY=:0 nohup xeyes < /dev/null > std.out 2> std.err &' |
Print the average time of 4 ping requests to "www.stackoverflow.com" | ping -c 4 www.stackoverflow.com | tail -1| awk '{print $4}' | cut -d '/' -f 2 |
Save the "Pictures" directory in the current user's home directory on the directory stack | pushd /home/`whoami`/Pictures |
Save the absolute path of the current script to variable "SELF" | actual_path=$(readlink -f "${BASH_SOURCE[0]}") |
Find all files under current directory and show their file information | find . -type f -exec file {} \; |
Create a symbolic link in directory "new" for each file in "original" directory tree | find original -type f -exec ln -s {} new/{} \; |
recursively change owner of the directory testproject and all files into it to user ftpuser | chown ftpuser testproject/ -R |
find regular/normal files in the current folder | find -type f |
List all regular files in the current directory tree modified within the last 24 hours | find . -mtime 0 -type f -ls |
Execute 'bash -c "python -m unittest discover |& pyrg"' every second and display with color support | watch -n 1 --color 'bash -c "python -m unittest discover |& pyrg"' |
Find all PNG and JPG files and append them to archive `images.tar' | find . \( -iname "*.png" -o -iname "*.jpg" \) -print -exec tar -rf images.tar {} \; |
Save all directories under the current directory as a comma separated list in variable "FOLDERS" | FOLDERS=$(find . -type d | paste -d, -s) |
Print "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" and append to file "/etc/apt/sources.list" | echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list |
delete all normal/regular files in the current folder which are empty | find . -type f -empty -delete |
Shows only IP4, not IP6 address of network interface eth0. | /usr/bin/ifconfig eth0 | grep --word-regexp inet | awk '{print $2}' |
find all the links in the current folder which are broken | find /target -type l -xtype l |
Print the most repeated line in "list2.txt" that exists in "list1.txt" prefixed by the number of occurrences | grep -Ff list1.txt list2.txt | sort | uniq -c | sort -n | tail -n1 |
Resolve symbolic link of file "FILE" even if the file does not exist | readlink -m FILE |
Extracts 258 lines beginning from line 16482 of in.sql and saves them to out.sql | head -16482 in.sql | tail -258 > out.sql |
Print the current user name associated with standard input | who -m | awk '{print $1;}' |
Find all files/directories matching the regex .*sql.* | find -regex .*sql.* |
Recursively finds all files older than 7 minutes under the current directory, saves list of found files, and compresses them, executing at most 10 compress process at a time. | find . -type f -mtime +7 | tee compressedP.list | xargs -I{} -P10 compress {} & |
find all jar files in current folder and search for a file in all these jar's and display the jar names along with searched file | find . -name "*.jar" -exec unzip -l {} \;|grep -E "Archive:|message_track.properties" |
Print the lines of file "strings" not specified in file "index" | join -v 2 index <(nl strings) |
Print a hex dump byte to byte of the output of "echo Aa" | echo Aa | od -t x1 |
Find all directories named "D" in the current directory tree | find . -name "D" -type d |
Find all files inside all directories in /tmp/test directory and print the number of files in each directory and also print the file name and directory paths | find . -type d -print0 | xargs -0 -I {} sh -c ' echo "{}: \c" ; find {} -maxdepth 1 -type f | wc -l ; find {} -maxdepth 1 -type f -print | sed "s#.*/##" ' |
Find and print the names of all files found in the current directory and all of its sub-directories. | find . |
Interactively display all lines containing 'word' in all files whose name ends with .properties in the current directory, waiting for user input after each page. | grep -R 'word' *.properties | more |
Resolve all symlinks in path to "firefox" binary if it exists in path, resulting in absolute path with no symlinks. | readlink -f $(which firefox) |
use find command to search for .png and .jpg files | find ./ -type f \( -iname \*.jpg -o -iname \*.png \) |
Find all *.err files under current directory that are larger than 5120 bytes in size | find . -type f -size +10 -name "*.err" |
search for all the php files in the folder "/home/mywebsite" which have been changed in the last 30*24 hours | find /home/mywebsite -type f -name "*.php" -ctime -30 |
Find all *.txt files under current directory that match the regex c|d|z in their names | find . -name '*.txt' | perl -lne 'print if /c|d|z/' |
Change permissions to 755 for all directories in the current directory tree | find . -type d | xargs chmod -v 755 |
find all the symbolic links in the current folder | find /etc -type l -print |
search for a file "file" in current folder and if the file is found quit ! | find -name file -quit |
For all users in the system who have their cron jobs display user name and crontab. | getent passwd | cut -d: -f1 | perl -e'while{chomp;$l = `crontab -u $_ -l 2>/dev/null`;print "$_\n$l\n" if $l}' |
Locate files with user permissions rwx owned by my_user | find . -user my_user -perm -u+rwx |
Find all files/directories named 'foo.rb' under current directory tree | find . -name foo.rb |
Find all TXT files on the system and copy them to /tmp/txt | find / -iname '*.txt' | xargs --replace=@ cp @ /tmp/txt |
display all the files in the current folder excluding those ending with ".disabled" in sorted order | find /target/ | grep -v '\.disabled$' | sort |
Find all files/directories under current directory tree that belong to the group 'compta' | find -group compta |
Display the content of YourFile.txt, waiting for user input at each page. | cat YourFile.txt | more |
search for all the files in the current folder which start with "my" | find . -name 'my*' |
search for the word echo all the bash files(files ending with .bash) in the current folder | find . -name "*.bash" |xargs grep "echo" |
find all the files in the current folder which have been modified in the last 60 minutes | find . -mmin -60 |
search for a word in all the regular files in the current folder. | find -type f -print0 | xargs -r0 grep -F 'example' |
Archive all filepattern-*2009* files/directories under data/ into 2009.tar | find data/ -name filepattern-*2009* -exec tar uf 2009.tar {} ; |
Remove trailing tabs in .java files from the current directory tree | find . -type f -name "*.java" -exec perl -p -i -e "s/[ \t]$//g" {} \; |
Change permissions to 777 for all directories in the current directory tree | find . -type d -exec chmod 777 {} \; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.