nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Find the first file/directory in ... directory and quit | find ... -print -quit |
find all the "error_log" files in the folder "/home" which are bigger than 5MB and force delete them | find /home -size +5000000b -name "error_log" -exec rm -rf {} \; |
Execute md5sum command on files found by the find command | find -iname "MyCProgram.c" -exec md5sum {} \; |
Print lines of 'file' reverted order, and reverted characterwise | tac file | rev |
Remove all files with names like "vmware-*.log" from the current directory tree | find . -name vmware-*.log -delete |
find all files in current folder having the name pattern "some_pattern" and move them to the folder target_location | find . -name some_pattern -print0 | xargs -0 -i mv {} target_location |
Print the absolute path of "$path" | readlink -f "$path" |
Search the current directory tree for executable regular files | find . -executable -type f |
list all samba files in /var/l* directory ( /var/lib or /var/log ) | find /var -path */l??/samba* |
Lists all subdirectories in a current folder, removing trailing slash. | ls -d */|sed 's|[/]||g' |
Print a list of each file with the full path prefix in the current directory tree excluding symbolic links | tree -fi |grep -v \> |
get all files in a current directory modified in the last 7 days | find . -mtime -7 -print0 | xargs -0 tar -rf /foo/archive.tar |
find regular files under the current directory, whose name ends in .mbox and rename each file, to the same name without .mbox at the end | find . -type f -wholename \*.mbox | sed 's/\(.*\)\.mbox/mv "\1.mbox" "\1"/' | sh |
Find all aliencoders.[0-9]+ files under /home/jassi/ directory | find /home/jassi/ -type f -name "aliencoders.[0-9]+" |
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 |
Find all regular files in .git and replace every occurrences of 'subdomainB.example.com' with 'subdomainA.example.com' in those files | find .git -type f -print0 | xargs -0 sed -i 's/subdomainB\.example\.com/subdomainA.example.com/g' |
prevents curl from returning error (23) Failed writing body when grepping for foo | curl "url" | tac | tac | grep -qs foo |
Find all .svn directories under current directory and delete them | find . -type d -name ".svn" -print | xargs rm -rf |
Recursively finds files like '*.js', and filters out files with 'excludeddir' in path. | find . -name '*.js' | grep -v excludeddir |
Find all 400 permission files under /data directory | find /data -type f -perm 400 -print |
Find files which were changed in the past 1 hour | find . -cmin -60 |
Continuously write "Hidden" over the entire "/dev/sdb" disk | yes "Hidden" | dd of=/dev/sdb |
Copy the standard output of a "bash" session to "/var/log/bash.out.log" | bash | tee /var/log/bash.out.log |
create symbolic links in current directory to all files located in directory "/original" and have filename extension ".processname" | ln -s $(echo /original/*.processme) . |
Search the current directory tree for hidden files skipping .htaccess | find . -type f \( -iname ".*" ! -iname ".htaccess" \) |
Pipe content of 'somedata.txt' file to the input of command "$outfile" | cat somedata.txt | "$outfile" |
List all files in entire file system that are newer than the file $newerthan and older than the file $olderthan and sort them according to file modification time | find / -type f -name "*" -newermt "$newerthan" ! -newermt "$olderthan" -printf '%T@ %p\n' | sort -k 1 -n | sed 's/^[^ ]* //' |
Merge colon-separated information from standard input and file1.txt where the first field of both files matches, print unpairable lines from both files, replace missing fields with "no-match", and output the second field from standard input and the second and third field from file1.txt | join -t, -o 1.2,2.2,2.3 -a 1 -a 2 -e 'no-match' - <(sort file1.txt) |
Find all files of the user with UID=1000 | find -user 1000 |
List all files in the /var directory tree whose size is greater than 10 megabytes | find /var/ -size +10M -ls |
Recursively change ownership of "~/.npm" to the current user | sudo chown -R `whoami` ~/.npm |
Find all files/directories under ./var/log directory | find ./var/log |
search for the word hello in all the text files in the temp folder and delete them | find /tmp -type f -name β*.txt*β | sed -e βs/.*/\β&\β/β |xargs -n 1 grep -l hello|sed -e βs/.*/\β&\β/β|xargs -n 1 rm -f |
Create a symbolic link in the current directory for each file .dbf under the directories matching "/home/michael/foxpro/mount/A[1FV]/[12][0-9][0-9][0-9]" | find /home/michael/foxpro/mount/A[1FV]/[12][0-9][0-9][0-9] -name '*.dbf' -type f -exec ln -s {} \; |
Find all regular files in the current directory tree and print a command to move them to the current directory | find . -type f -exec echo mv -t . {} + |
Save all entries that are wrapped around with opening and closing square brackets in file 'FILENAME' to variable 'var' | var=`egrep -o '\[.*\]' FILENAME | tr -d ][` |
Report total file systems disk usage. | df --total | tail -n 1 |
Search the current directory recursively for regular files last accessed more than 2 minutes ago | find . type -f -amin +2 |
Installs 'packagename' package. | yum install packagename |
find the file "foo.txt" in the current folder and assign the output to a variable | OUTPUT=`find . -name foo.txt` |
Prints process tree, showing only strings with 'MDSImporte', and chopping output after ${WIDTH} characters. | pstree | grep MDSImporte | cut -c 1-${WIDTH} |
Create compressed archive of all the files in the current directory tree that have been modified in the last 7 days | find . -type f -mtime -7 -print -exec cat {} \; | tar cf - | gzip -9 |
Find all PHP files under current directory that contain only one line | find -name *.php -print | xargs -L1 awk 'NR>1{exit} END{if print FILENAME}' |
Counts all files in a current folder and in subfolders one-level lower and sorts result by number of files within. | find . -maxdepth 1 -type d -print0 | xargs -0 -I {} sh -c 'echo -e $ "{}"' | sort -n |
Find all files and directories whose names end in ".rpm" and change their permissions to 755 | find / -name *.rpm -exec chmod 755 '{}' \; |
prevents curl from returning error Failed writing body when grepping for foo | curl "url" | tac | tac | grep -qs foo |
Print percentage of the space used on the $FILESYSTEM. | df -k $FILESYSTEM | tail -1 | awk '{print $5}' |
Check if a drive is mounted to nfs | mount |grep nfs |
display all the regular/normal files in the entire file system | find / -type f -exec echo {} \; |
search for a word in all files in a directory | find /directory/containing/files -type f -print0 | xargs -0 grep "test to search" |
Recursively copy directory "/path/to/data/myappdata" to "user@host:/remote/path/to/data/myappdata" | rsync -rvv /path/to/data/myappdata user@host:/remote/path/to/data/myappdata |
Search directory /Users/david/Desktop/ recursively for regular files with extensions .txt, .mpg, .jpg | find /Users/david/Desktop -type f \ |
Find all files that belongs to user root under / directory and show a few lines of output from the beginning | find / -user root | head |
Find all regular files under and below /home/user/demo/ | find /home/user/demo -type f -print |
Counts lines in each *.php file. | find . -name '*.php' -type f | xargs wc -l |
removes the 4th-from to 6th-from last lines in file | tac filename | sed 4,6d | tac |
List environment variables whose name matches '^\w*X\w*' | set | grep -oP '^\w*X\w*' |
Changes group ownership of /sys/class/gpio/export and /sys/class/gpio/unexport to 'gpio'. | sudo chgrp gpio /sys/class/gpio/export /sys/class/gpio/unexport |
Store N symbols of input into variable 'buffer' | read -N $BUFSIZE buffer |
Find all .bak files starting from the current directory and delete them | find . -iname "*.bak" -type f -print | xargs /bin/rm -f |
Print the login time and user of the first person who logged in | who | awk '{print $3 " " $4 " "$1}' | sort | head -1 |
find the type of all the regular/normal files in the current folder | find . -type f -exec file {} \; |
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 |
Delete all shared memory and semaphores for the current user on sun | ipcs | nawk -v u=`whoami` '/Shared/,/^$/{ if print "ipcrm shm",$2,";"}/Semaphore/,/^$/{ if print "ipcrm sem",$2,";"}' | /bin/sh |
Calculate the MD5 checksums of all files from directory tree //path/to/source/Directory and save them as Output.txt | find //path/to/source/Directory -type f -exec md5sum {} + | awk '{print $0}' > Output.txt |
Finds out what groups a current user has. | groups |
Search the /path tree for all executables | find /path -perm /ugo+x |
ssh into default vagrant host without running "vagrant ssh" by passing the configuration parameters vagrant uses for ssh | ssh [email protected] -p 2222 -o Compression=yes -o DSAAuthentication=yes -o LogLevel=FATAL -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i ~/.vagrant.d/less_insecure_private_key -o ForwardAgent=yes |
Print characters in variable "$a" that exist in variable "$b" | echo "$(comm -12 <(echo "$a" | fold -w1 | sort | uniq) <(echo "$b" | fold -w1 | sort | uniq) | tr -d '\n')" |
Print each line that is found only once in "file1" and "file2" combined | sort file1 file2 | uniq -u |
Gets IP addresses of all active network interfaces. | ifconfig | grep -oP "(?<=inet addr:).*?(?=Bcast)" |
search in the current folder for all the regular/normal file with the name "test" | find . -type f -name test |
unsafed rm all file which name start with '#' | find / -name '#*' -atime +7 -print | xargs rm |
Find all files under current directory | find . -type f |
sleep for 500 seconds | sleep 500 |
delete all the files in the file system which belong to the user edwarda after user confirmation | find / -user edwarda -ok rm "{}" \; |
Write output and error of "update-client" to standard output and to "my.log" | update-client 2>&1 | tee my.log |
Saves location of file $1 in 'dir' variable. | dir=$(dirname -- "$1") |
Find all regular files in the current directory tree last modified between 1 and 3 days ago and list them using format '%TY %p\n' | find ./ -daystart -mtime -3 -type f ! -mtime -1 -printf '%TY %p\n' |
Search for line number 111 in file "active_record.rb" | nl -ba -nln active_record.rb | grep '^111 ' |
Create a gzip archive file of all *.log files under $sourcePath | find $sourcePath -type f -name "*.log" -exec tar -uvf $tarFile {} \; |
Print file type of the executable file of command "file" | which file | file -f - |
change the owner of all the files in the current directory | find . -exec chown myuser:a-common-group-name {} + |
Print file extension assuming there is only one dot in the file name. | echo "$FILE" | cut -d'.' -f2 |
search for the file "process.txt" in the entire file system (case insensitive search) | find / -iname 'process.txt' -print |
search for the files "foo.txt" in the current folder and rename it to foo.xml | find -name foo.txt -execdir rename 's/\.txt$/.xml/' '{}' ';' |
Convert Unix `cal` output to latex table code. | cal -h 02 2012| cut -c4-17 | sed -r 's/\s/\0\t\&/g' | sed 's/$/\t\\\\/' | head -n-1 | tail -n +2 |
Replace "version.old" with "version.new" in the symbolic link target of "SomeLibrary" | ln -f -s -T `readlink SomeLibrary | sed 's/version.old/version.new/'` SomeLibrary |
Find the total size of *.jpg files within the current directory tree | find . -type f -iname '*.jpg' -print0 | du -c --files0-from=- |
Find all files in the current directory tree whose path names match pattern './sr*sc' | find . -path './sr*sc' |
Output the system host name and date to the console | echo Hostname=$(hostname) LastChecked=$(date) |
Find all SUID files in entire file system | find / -perm +4000 |
Find files that were accessed in less than a day ago | find / -atime -1 |
Find all files under current directory and set read permission for group and other for these files | find . -type f -print0 | xargs -0 chmod go+r |
Getting a detailed list of files/dirs | find / -name "apt" -ls |
Run /bin/true with 1 to 100000 as arguments | /bin/sh -c "/bin/true $" |
Search the current directory tree for regular files whose names end in ".shtml" or ".css" | find . -type f \ -print |
create a gzip of all the files in the current folder excluding the already gzipped files | gzip `find . \! -name '*.gz' -print` |
Set the system date to Sat May 11 06:00:00 IDT 2013 | sudo date --set="Sat May 11 06:00:00 IDT 2013" |
Print timestamp as HH:MM:SS | date +"%T" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.