nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Find all files/directories with permission $permissions under $directory directory tree
|
find "$directory" -perm "$permissions"
|
Adjust the timestamp of 'filename' by subtracting 2 hours from it.
|
touch -d "$(date -r filename) - 2 hours" filename
|
Search $MYGROUP in /etc/group, take the 4th colon separated field, replace comma with newline and save the result to variable 'MYUSERS'
|
MYUSERS=`grep $MYGROUP /etc/group | cut -d ":" -f4| tr "," "\n"`
|
Compare files "A1" and "A2" with 3 lines of unified context and print lines beginning with "+"
|
diff -u A1 A2 | grep -E "^\+"
|
Counts all files in a current folder and subfolders.
|
find -type f -printf '\n' | wc -l
|
Search the .java files from the current directory tree for TODO lines
|
find . -name "*.java" -exec grep -i -n TODO {} \;
|
Recursively finds and compresses all files in a current folder.
|
find . -type f -exec bzip2 {} +
|
Archive "foo/bar/baz.c" to "remote:/tmp/" preserving the relative path of "foo/bar/baz.c"
|
rsync -avR foo/bar/baz.c remote:/tmp/
|
SSH into "$NAME" as user "${USERNAME}" using key file "${KEYDIR}/${KEY}.pem", automatically add the host to list of known hosts and execute "${COMMANDS}"
|
ssh -o "StrictHostKeyChecking no" -i ${KEYDIR}/${KEY}.pem ${USERNAME}@$NAME "${COMMANDS}"
|
List the commands in /usr/bin, pausing for user input after each page.
|
more <( ls /usr/bin )
|
display all sqlite files in the current directory along with their timestamp
|
find ./ -name "*.sqlite" -printf '%Tc %p\n'
|
Deletes folder like /tmp/*/* or deeper, older than +7 days if they don`t contain files or other folders.
|
find /tmp/*/* -mtime +7 -type d -exec rmdir {} \;
|
change owner and group of the current directory and all files into it to user and group andrew
|
chown -R andrewr:andrewr *
|
Find all .php files in all directory trees matching pattern `/srv/www/*/htdocs/system/application/' and search those files for string "debug ("
|
find /srv/www/*/htdocs/system/application/ -name "*.php" -exec grep -H "debug (" {} +
|
Search the entire file hierarchy for files ending in '.old' and delete them.
|
find / -name "*.old" -exec /bin/rm {} \
|
change the permission of all directories in current folder to 755.
|
find . -type d -exec chmod 755 {} \;
|
Move all *.pdf.marker files and their corresponding *.pdf files under ${INPUT_LOCATION} to ${OUTPUT_LOCATION}
|
find $INPUT_LOCATION -name '*.pdf.marker' | xargs -i bash -c 'mv ${0%.marker} $0 $1' {} $OUTPUT_LOCATION
|
List the files in the /etc directory tree containing text '128.200.34.'
|
find /etc -type f -print | xargs grep -il '128\.200\.34\.'
|
Print 10 space separated "x"s with at most 4 per line
|
yes x | head -10 | awk 'BEGIN { RS = "%%%%%%%" } { split($0,a,"\n"); for (i=1; i<length(a); i+=4) print a[i], a[i+1], a[i+2], a[i+3] }'
|
Report file system containing path to /dir/inner_dir/ disk usage human-readable.
|
df -h /dir/inner_dir/
|
Print a sorted list of the extensions of the regular files from the current directory tree with counts per extension
|
find . -type f | perl -ne 'print $1 if m/\.$/' | sort | uniq -c | sort -n
|
Find all catalina* files/directories under current directory
|
find -name 'catalina*'
|
Fix files to default permissions 644
|
find . -type f -exec chmod 644 {} \;
|
search for "flac" files in current folder using regular expressions
|
find ./ -regex "./cmn-.\.flac"
|
Find files and directories owned by xuser1 and change their ownership to user2
|
find . -user xuser1 -exec chown -R user2 {} \;
|
Uninstalls and then installs git formula.
|
brew reinstall git
|
Saves list of currently logged in users in 'userlist' variable.
|
userlist=$
|
Find files whose data was modified within the given days of the month
|
find ./ -daystart -mtime -10 -and -mtime +1
|
Remove the passphrase from ~/.ssh/id_rsa.
|
ssh-keygen -f ~/.ssh/id_rsa -P ""
|
Remove regular files whose names match Perl regular expression '\w+-\d+x\d+\.\w+$' from the current directory tree
|
find -type f | grep -P '\w+-\d+x\d+\.\w+$' | xargs rm
|
Print second section of space-separated data coming from stdin.
|
cut -d ' ' -f 2
|
Use the last 100 lines of "file1" as input to "wc -l" and monitor the pipeline with the "pv" command
|
tail -n 100 file1 | pv | wc -l
|
Find the empty directories and files under current directory
|
find -empty
|
Disable wildcard expansion and name globbing
|
set -f
|
Create an empty file "foo" in each directory under the current directory containing a file named "bar".
|
find -name "bar" -execdir touch foo \;
|
Find all files/directories in entire file system that are owned by "syslog" user
|
find / -user syslog
|
Search for 'example' in all regular files from the current directory
|
find -maxdepth 1 -type f | xargs grep -F 'example'
|
Print the percentage of packets lost of the 5 packets sent to "$host"
|
ping -c 5 -q $host | grep -oP '\d+(?=% packet loss)'
|
Change the permissions of all regular files whose names end with .mp3 in the directory tree /var/ftp/mp3
|
find /var/ftp/mp3 -name '*.mp3' -type f -exec chmod 644 {} \;
|
View history using "vim"
|
vim <(history)
|
Creates temporary folder in /tmp/ (by default) with 10-letter suffux.
|
mktemp -d -t
|
Find files/directories under current directory matching the posix-egrep type regex ".+\.$" in their names
|
find . -regextype posix-egrep -regex ".+\.$"
|
Gets IP address of 'en0' network interface.
|
ip addr show en0 | awk '$1 == "inet" {gsub; print $2}'
|
Print list of disk and mountpoint of disks matching "/dev/sd*"
|
paste <(mount | awk 'tolower ~ /\/dev\/sd*/ {print NR "\t" $1 "\t" $3}') <
|
Print numbers from 1 to 10 with 2 values per line
|
seq 10 | sed '2~2G' | awk -v RS='' '{$1=$1; print}'
|
search for files in the current folder using name patterns
|
find . -name '[mM][yY][fF][iI][lL][eE]*'
|
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" -print -exec jar -tf {} \; | awk '{ifjar=$1;else ifarr[jar]=$1;}END{for{print i " contains " arr[i]}}'
|
display all the regular files in current folder excluding all the directories and all the sub directories having "normal" in their name
|
find . \( \( -path "\.?.*" -type d \) -o -path "*normal*" \) -prune -o \( -type f \) -print
|
Create a named screen session
|
screen -X title mynewtitle
|
For each line which has a common first field in test.1 and test.2, output the first 2 fields of test.2 and the field 2 and 3 of test.1
|
join -j1 -o 2.1,2.2,1.2,1.3 < <
|
List all *.txt files/directories under current directory
|
find . -name "*.txt" -print
|
Compress all files in the "$FILE" directory tree that were last modified 30 days ago and have not already been compressed with gzip
|
find $FILE -type f -not -name '*.gz' -mtime 30 -exec gzip {} \;
|
Send SIGTERM signal to all processes using TCP port 8080, requesting them to terminate.
|
kill $
|
Print content of all files found regarding seach options '[whatever]'
|
find [whatever] -print0 | xargs -0 cat
|
Rename $file file, preserving only part of name before '-' symbol, and appending '.pkg' suffix to the end
|
mv $file $.pkg
|
display a list of all java or jsp files in the current folders
|
find . \( -name '*jsp' -o -name '*java' \) -type f -ls
|
Search the entire file hierarchy for files ending with '~' and print all matches except for those with '/media' in their pathnames.
|
find / -name "*~" | grep -v "/media"
|
Find all files beneath the current directory that end with the extension .java and contain the characters String ignoring case. Print the name of the file where a match is found.
|
find . -type f -name "*.java" -exec grep -il string {} \;
|
Print a welcome message with the current user's user name
|
echo -ne "Welcome $(whoami)!\n"
|
Decompress 'file.gz' to standard output and execute the output in bash
|
gzip -d --stdout file.gz | bash
|
Unset RBENV_VERSION variable from within tmux session.
|
tmux set-environment -u RBENV_VERSION
|
Change owner to "root" and group to "wheel" of "bin"
|
sudo chown root:wheel bin
|
Determine if user "$USER" is logged in
|
who | grep $USER
|
search for a word in all the files in the current directory
|
find . -exec grep chrome {} \;
|
Search the current directory tree for regular files changed on the 10th of September
|
find ./ -type f -ls |grep '10 Sep'
|
Find all your text files
|
find . -name "*.txt" -print
|
Execute `somecommand' on each file from the current directory tree with the environment variable f set to the filename
|
find . -exec env f={} somecommand \;
|
Search for all files in the /home directory tree that have the same inode number
|
find /home -xdev -inum 2655341
|
Find out if there are any files on the system owned by user `account'
|
find / -path /proc -prune -o -user account -ls
|
Remove sess_* files that were modified more than 2 days ago
|
find sess_* -mtime +2 -exec rm {} \;
|
Find all files matching pattern '.#*' in the current directory tree
|
find -iname '.#*'
|
Remove all files containing 'sample' in their names under '/home/user/Series' directory tree
|
/usr/bin/find /home/user/Series/ -iname "*sample*" -exec rm {} \;
|
Rotates the dirs stack so that the second directory is at the top.
|
pushd -2
|
Search for 'class Pool' in all *.java files under current directory
|
find -iname '*.java'|xargs grep 'class Pool'
|
Search the current directory tree for regular files that contain "string"
|
find . -type f -print0 | xargs -0 grep string
|
Output "file.txt", omitting all containing directories "some/unknown/amoutn/of/sub/folder/"
|
basename "some/unknown/amount/of/sub/folder/file.txt"
|
Treat references to unset variables as errors
|
set -o nounset
|
Ping all hosts in file "ips" twice
|
cat ips | xargs -i% ping -c 2 %
|
Counts all top-level files in a current folder.
|
ls -1 | wc -l
|
bind key "\x61" to insert itself
|
bind $'"\x61"':self-insert
|
Find all files/directories under $1 which have at least write permission for their owner and set write permission for group for these files/directories
|
find $1 -perm -u+w -exec chmod g+w {} \;
|
Execute "wget -qO- http://fake.link/file.txt | tail" every 5 seconds
|
watch -n 5 "wget -qO- http://fake.link/file.txt | tail"
|
Read a line from standard input into variable "message" with escaped prompt "\nPlease Enter\na Message: '"
|
read -p "`echo -e '\nPlease Enter\na Message: '`" message
|
find all the files that have been modified today
|
find . -type f -mtime 0
|
find all the files ending with ".coffee" in the current folder and search for the first occurence of the word "re" in each line
|
find . -name '*.coffee' -exec awk '/re/ {print;exit}' {} \;
|
Search /var for files matching regular expression '.*/tmp/.*[0-9]*.file'
|
find /var -regex '.*/tmp/.*[0-9]*.file'
|
search character special files called ' backup ' from /usr directory downwards and print them .
|
find /usr -type c -name backup -print
|
Find all *.jpg files and copy them to /
|
find / -type f -name *.jpg -exec cp {} . \;
|
Create a symbolic link named ".profile" to "git-stuff/home/profile" without dereferencing ".profile"
|
ln -sn git-stuff/home/profile .profile
|
Ping the broadcast address "10.10.0.255"
|
ping -b 10.10.0.255
|
Convert relative path "/x/y/../../a/b/z/../c/d" into absolute path with resolved symbolic links
|
readlink -f /x/y/../../a/b/z/../c/d
|
Show find's version
|
find --version
|
Find the file whose inode number is 1316256
|
find . -inum 1316256
|
display all symbolic links in current folder
|
find . -lname "*"
|
login as user root
|
su -l
|
List all .svn files/directories under current directory
|
find . -name .svn -exec ls {} \;
|
Force decompress all files into '/etc'
|
gzip -d --force * /etc
|
Display the sizes and filepaths of all files/directories with '.undo' extension under current directory tree
|
find -name *.undo -print0 | du -hc --files0-from=-
|
Find all the files in file system which are accessed 50 days back
|
find / -atime 50
|
Recursively removes all folders named '.svn' in a current folder.
|
find . -type d -name .svn -print0|xargs -0 rm -rf
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.