nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Search for 'whatIWantToFind' in all files under current directory | find . -exec grep whatIWantToFind {} \; |
Find all files and directories in the current directory tree except those whose name is "dirname", case insensitive | find ./ -iname ! -iname dirname |
find all the files in the filesystem which do not belong to any group | find / -nogroup -print |
List all regular files from the current directory tree that were modified less than 60 minutes ago | find . -type f -mmin -60 -print0 | xargs -r0 ls -l |
Find all files whose owner is `user1' | find / -user user1 |
Convert *.au files to *.wav files using `sox' | find -type f -name '*.au' | awk '{printf "sox %s %s\n",$0,$0".wav" }' | bash |
Search the entire file system for .jpg files. | find / -name “*.jpg” |
Print each line in "file1" whose first word does not exist as the first word of any line in "file2" | join -v 1 <(sort file1) <(sort file2) |
ssh into "hostname" as user "buck" | ssh -l buck hostname |
Display the number of regular files under current directory tree | find . -type f -print0 | tr -dc '\0' | wc -c |
For each line which has a common first field in file1.csv and file2.txt, output the first 4 fields of file1.csv - both files must be sorted first. | join -o 1.1,1.2,1.3,1.4 -t, file1.csv file2.txt |
Print position number of day '9' in fourth line of calendar output for September, 2009. | cal 09 2009 | awk '{day="9"; if (NR==4) {col=index($0,day); print col } }' |
Find regular files in the current directory tree that have any executable bits set | find -L . -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) |
Print the contents of "foo.txt" starting with line 2 | tail -n +2 foo.txt |
Find symbolic links in /usr/sbin and /usr/bin to files whose pathnames end in "*/systemctl" | find /usr/sbin /usr/bin -lname "*/systemctl" |
Remount "yaffs2" filesystem "/dev/block/mtdblk4" to "/system" as read only | mount -o ro,remount -t yaffs2 /dev/block/mtdblk4 /system |
Change to the directory of the executable "<file>" | cd `which <file> | xargs dirname` |
View contents of files matching "/usr/share/doc/mysql-server-5.0/changelog*.gz" in "less" | zcat /usr/share/doc/mysql-server-5.0/changelog*.gz | less |
Display all symlinks and their targets in the current directory tree | find -P . -type l -exec echo -n "{} -> " \; -exec readlink {} \; |
Print 10 space padded "x"s to a width of 10 with at most 4 per line | printf '%-10s%-10s%-10s%s\n' $ |
Create an empty file in each directory named "mydir" under current directory. | find . -type d -name "mydir" -print | sed 's/$/\/abc.txt/g' | xargs touch |
Find files using file-name | find -iname "MyCProgram.c" |
Remove all regular files found in and below /path | find /path -type f -exec rm '{}' + |
Find files in the current directory tree that are named "some_pattern" and move them to directory "target_location" | find . -name some_pattern -print0 | xargs -0 -i mv {} target_location |
display all the html files in the current folder | find . -name \*.html |
Search for hidden files non-recursively | find . -name '.?*' -prune |
Recursively set all permissions under "/directory" to 755 | chmod -R 755 /directory |
display all the files in the current folder excluding those which are in the path of ".git" | find . ! -path "*.git*" -type f -print |
Find all $2 files in $1 path excluding /proc and search for the regex expanded by $3 in those files | find $1 -path /proc -prune -o -name "$2" -print -exec grep -Hn "$3" {} \; |
display long listing of all the files in the folder "/myfiles" | find /myfiles -exec ls -l {} ; |
Find suspicious PHP files | find . -type f -name "*.php" -exec grep --with-filename "eval(\|exec(\|base64_decode(" {} \; |
Delete all regular files named 'IMAGE1806.jpg' under current directory tree | find . -type f -name 'IMAGE1806.jpg' -delete |
Mark variables and function which are modified or created for export to the environment of subsequent commands | set -a |
Search the system for *.rpm files ignoring removable media | find / -xdev -name \*.rpm |
find all the files in the file system which have the permission 777 and with the name "dateiname" | find / -perm 777 -iname "Dateiname" |
Display the file size of file '/data/sflow_log' in bytes | du -sb /data/sflow_log | cut -f1 |
Find all TXT files in the current directory and copy them to directory "$HOME/newdir" | find "$HOME" -name '*.txt' -type f -print0 | xargs -0 cp -ut "$HOME/newdir" |
display all files in current folder which have been modified in the last 60 minutes | find -mmin 60 |
Search the *.code files from the current directory tree for string 'pattern' | find . -name '*.code' -exec grep -H 'pattern' {} + |
display all normal/regular files in current folder | find . -type f -print0 |
change the permissions of mp3 files in the folder /var/ftp/mp3 to 644 | find /var/ftp/mp3 -name '*.mp3' -type f -exec chmod 644 {} \; |
Set variable "finalName" to the second-to-last slash-separated path component of variable "path" | finalName=$(basename -- "$(dirname -- "$path")") |
Delete empty regular files | find . -type f -empty -delete |
search for the files with the name "temp" and which have not been accessed in the last 7*24 hours in the /usr folder | find /usr -name temp -atime +7 -print |
Print the sorted and unique parent directory paths appended with : of all the files that are executable by owner under ~/code directory without descending into hidden directories | find ~/code -name '.*' -prune -o -type f -a -perm /u+x -printf ':%h\n' | sort | uniq | tr -d '\n' |
display all files in current folder which are bigger than 1 MB | find . -size +1M |
Print file system disk space usage and grand total for the root file system with sizes in powers of 1000 | df -H --total / |
Display "/tmp/file" as a table of width 30 with columns filled before rows | column -x -c 30 /tmp/file |
Find all files/directories under /var/log directory | find /var/log |
find all the files in the current directory which end with orig | find . -name '*.orig' -exec echo {} \ ; |
Create an empty file "foo" in each directory under the current directory containing a file named "bar". | find -name "bar" -execdir touch foo \; |
Split "abc.txt" into files with at most 1500000000 bytes each and use prefix "abc" | split --bytes=1500000000 abc.txt abc |
Finds all files with names like "*.rm" in a '/home/me/download/' folder, launches ffmpeg conversion for each one, and deletes source file after. | find /home/me/download/ -type f -name "*.rm" -exec ffmpeg -i \{} -sameq \{}.mp3 \; -exec rm \{} \; |
find all the files in the home folder which have been modified in the last 24 hours | find $HOME -mtime -1 |
Find & Write Changes to a File and Print the Changes Using sed s//gpw | find . -type f -name "*.txt" -exec sed -n 's/Linux/Linux-Unix/gpw output' thegeekstuff.txt |
Calculate MD5 sums for all regular files in the current directory tree | find . -type f | while read f; do g=`md5sum $f | awk '{print $1}'`; echo "$g $f"> $f-$g.md5; done |
Find all regular files under $SOURCE directory tree that were modified more than $KEEP days ago and show only the names without the paths | find $SOURCE -type f -mtime +$KEEP | sed ‘s#.*/##' |
Copy all ".php" files in "projects/" directory tree to "copy/" preserving directory hierarchy | find projects/ -name '*.php' -print | cpio -pdm copy/ |
Find all files/directories in current directory and run the command 'command' on each of them invoking the command as few times as possible | find -exec command {} + |
Find files smaller than 40 blocks skipping directories on other file systems | find . -size -40 -xdev -print |
Print content of all files found regarding seach options '[whatever]' | find [whatever] | xargs cat |
Show manual page of find | man find |
Execute "/wherever/whatever" in the background on target machine "user@host" | ssh -n -f user@host "sh -c 'cd /whereever; nohup ./whatever > /dev/null 2>&1 &'" |
find files in the /usr/src directory with pattern` *.c that larger than 100 Kilobytes | find /usr/src -name '*.c' -size +100k -print |
Delete all files under /path/to/input/ that match the case insensitive string literal '[email protected]' in their contents | find /path/to/input/ -type f -exec grep -qiF [email protected] \{\} \; -delete |
Find all empty directories under /tmp and below | find /tmp -type d -empty |
List environment variables and their values, escaping all semicolons with a backslash. | env | sed 's/;/\\;/g' |
List files and directories one level deep in the current directory tree | tree -L 2 |
converts all absolute symbolic links to relative symbolic links | find . -lname "`pwd`*" -exec sh -c 'ln -snvf `python -c "from os.path import *; print relpath(\"$\",dirname)"` {}' \; |
find all the config files in the folder /home/pat | find /home/pat -iname "*.conf" |
Search the current directory and all subdirectories for files that have 777 permissions and the permissions to 755 | find . -type f -perm 777 -exec chmod 755 {} \; |
Report all files in /mydir1 and /mydir2 larger than 2000 blocks and accessed in over 30 days | find /mydir1 /mydir2 -size +2000 -atime +30 -print |
split the first 100 lines of the file "datafile" per lines with size 1700 bytes | sed 100q datafile | split -C 1700 - |
find all files in current folder which are bigger than 1 MB and move them to another folder after user confirmation | find . -size +1M -ok mv {} files \+ |
Display long listing of all the files/directories owned by the user 'me' under '/tmp' directory tree | find /tmp -user me -ls |
Search the current directory tree for .log files containing the string "The SAS System" on the first line | find . -name '*.log' -type f -readable ! -size 0 -exec sed -n '1{/The SAS System/q0};q1' {} \; -print |
Move all files and directories in the current directory to "/tmp/blah/" | mv * /tmp/blah/ |
Display a long list of all the files/directories named ".todo" under $STORAGEFOLDER directory tree | find $STORAGEFOLDER -name .todo -exec ls -l {} \; |
find all the files that are not modified in the last 7 days | find -daystart -mtime +7 |
Remove all files with the .c extension in the current directory tree | find . -name "*.c" -print0 | xargs -0 rm -rf |
Send content to screen session windows with a certain title | screen -S SessionName -X at ".#" stuff "date " |
Request that the master ssh connection "otherHosttunnel" exits | ssh -O exit otherHosttunnel |
Archive "myfile" to "/foo/bar/" and create directory "/foo/bar/" if "/foo/" exists | rsync -a myfile /foo/bar/ |
find and delete all the files in the entire file system whose size is greater than 100MB. | find / -size +100M -exec rm -rf {} \; |
Find all /path/to/check/* regular files without descending into any directory | find /path/to/check/* -maxdepth 0 -type f |
find all the files in the current directory which have the inode number 31246 and remove them. | find . -inum 31246 -exec rm [] ';' |
Non-recursively finds all '*.pdf' files in a current folder and removes them. | find -maxdepth 1 -name '*.pdf' -exec rm "{}" \; |
Make directory and parents as needed to "~/temp/bluecove/target/" | mkdir -p ~/temp/bluecove/target/ |
Write "some output" to standard output and to "/some/path/some_file" as user "some_user" | echo "some output" | sudo -u some_user tee /some/path/some_file |
Find files/directories under current directory that matches './projects/insanewebproject' in their paths | find -ipath './projects/insanewebproject' |
display all the files ending with ".foo" including those that are in the directory ".snapshot", this is the wrong way of using prune. | find . \( -name .snapshot -prune -o -name '*.foo' \) -print |
Find all the *.pl files (Perl files) beneath the current directory. | find . -name "*.pl" |
Search the system for *.rpm files ignoring removable media | find / -xdev -name \*.rpm |
display all the ".mov" video files in the current folder in the format filename and folder path | find . -iname "*.mov" -printf "%p %f\n" |
Find SUID files | find / -perm +u=s |
Return all of the .conf files in Pat's user folder and subdirectories | find /home/pat -iname "*.conf" |
Find all the files whose name is FindCommandExamples.txt in the current working directory | find /root -name FindCommandExamples.txt |
Find all *.rb files/directories under current directory | find . -name \*.rb |
Print the current user's mail file in "/var/spool/mail" | cat /var/spool/mail/`whoami` |
Save a list of all 755 permission files/directories under $dir directory tree to the variable 'files' | files="$(find $dir -perm 755)" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.