nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Use "vagrant-ssh" as the config file and ssh into "default" host
ssh -F vagrant-ssh default
Search the home directory for OGG and MP3 files
find $HOME -iname '*.ogg' -o -iname '*.mp3'
display all text, mpg, jpg files in the folder /Users/david/Desktop
find /Users/david/Desktop -type f \
List all *.txt files/directories under /etc
find /etc -name "*.txt" -exec ls -l {} \;
Search for "facebook\|xing\|linkedin\|googleplus" in "access-log.txt" and print a count of the unique entries
grep -ioh "facebook\|xing\|linkedin\|googleplus" access-log.txt | sort | uniq -c | sort -n
Recursively changes group ownership of everything in '/home/secondacc/public_html/community/' to 'fancyhomepage'.
chgrp -R fancyhomepage /home/secondacc/public_html/community/
find files in the home folder which have been modified in the last day.
find ~/ -daystart -type f -mtime 1
Remove all files in the /myfiles directory tree that were accessed at least 30 days ago
find /myfiles -atime +30 -exec rm {} ;
Remove `core' files whose status was changed more than 4 days ago
find `pwd` -name core -ctime +4 -execdir /bin/rm -f {} \;
Calculate the sin values of the interval from 0 to pi/2 with a step of 1, add a line number, and write the output to standard output and "y.txt"
octave -q --eval 'printf ("%f\n", sin)'|nl|tee y.txt
Enables shell option 'expand_aliases'.
shopt -s expand_aliases
Print the list of 1st level subdirectories in /fss/fin
find /fss/fin -d 1 -type d -name "*" -print
display all the regular/normal files in the current directory which are atleast 2 levels deep
find . -mindepth 2 -type f
Find files with size more than 200557600B and which are more than 2 days old under ${userdir}/${i}/incoming directory
find ${userdir}/${i}/incoming -mtime +2 -type f -size +200557600c -ls
Finds all files in a '/path' folder and prints long listing for them.
find /path -type f -exec ls -l \{\} \;
Search for files only that end with .php and look for the string $test inside those files
find . -name \*.php -type f -exec grep -Hn '$test' {} \;
display all the files in the current directory excluding the paths "targert", "tools", "git"
find . \
find all the files in the current directory ending with ".i"
find . -name ".*\.i"
Join data in file1 containing one number per line with data in file2 containing a number and other information per line, keeping the same order as it is found in file1.
join -1 2 -2 1 -a1 <(cat -n file1.txt | sort -k2,2) <(sort file2.txt) | sort -k2 | cut --complement -d" " -f2
Find all directories in the current directory tree that do not have `execute' permissions for anyone
find . -type d ! -perm -111
find all the text files in the entire filesystem which belong to the user root and display the ten files.
find / -user root -iname "*.txt" | head
Move all files excluding hidden files in "/path/subfolder/" to "/path/"
mv /path/subfolder/* /path/
search for the file foo.txt in the entire file system
find / -name foo.txt
Join lines in file "A" with lines in file "B" if the lines share a common first word
join < <
Change the group of "myfile" to "friends"
chown :friends myfile
Set the host name to "myServersHostname"
hostname myServersHostname
List all files under current directory matching the regex '.*\.\(c\|h\|cpp\)'
find . -type f -regex '.*\.\(c\|h\|cpp\)' -exec ls {} \;
Find and remove all .core files
find / -name "*.core" | xargs rm
Removes all empty folders within $DELETEDIR folder.
find "$DELETEDIR" -mindepth 1 -depth -type d -empty -exec rmdir "{}" \;
Execute "ls -l data.temp" every 2 seconds
watch ls -l data.temp
Find files named core in or below the directory /tmp and delete them, processing filenames in such a way that file or directory names containing single or double quotes, spaces or newlines are correctly handled.
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
Print numbers from 1 to 10 using up to 4 processes
seq 10 | xargs -P4 -I'{}' echo '{}'
Search for files which have read and write permission for their owner and group, and which other users can read, without regard to the presence of any extra permission bits
find . -perm -664
Change the owner of the directory name of "$JBOSS_PIDFILE" to "${JBOSS_USER}" and always return successfully
chown ${JBOSS_USER}: $ || true
Set the system date to Sat May 11 06:00:00 IDT 2013
sudo date --set="Sat May 11 06:00:00 IDT 2013"
search for all the files in the current folder which have not been modified in the last 7 days and save the output to a file
find -mtime +7 -print > found.lst
Opens gcc info manual and goes to a node pointed by index entry "funroll-loops".
info gcc --index-search=funroll-loops
Fint all *.txt files/directories in entire file system without descending to other file system and without error reporting
find / -name "*.txt" -mount 2> /dev/null
find all the html files which are modified in the last 7 days
find . -mtime -7 -name "*.html"
List all files/directories under current directory
find . -ls
remove all the core files from /usr folder which have not been accessed in the last 7*24 hours
find /usr -name core -atime +7 -exec rm "{}" \;
display all files in the folder /usr and its sub directory
find /usr -maxdepth 1 -print
display all the html files in the current folder that have not been modified in the last 7*24 horus
find . -mtime +7 -name "*.html" -print
Find all directories under '/var/www' directory tree excluding '/var/www/web-release-data' and '/var/www/web-development-data' directories and their sub-directories
find /var/www -type d \
display all normal/regular files in current folder
find . -type f
list all files under the current directory, writing the output to the file files_and_folders, do not try to descend into directories that cannot be read.
find . -type d ! -perm -g+r,u+r,o+r -prune -o -print > files_and_folders
change the ownership of all regular/normal files in the current directory
find . -type f -exec chown username {} \;
Find all files/directories named 'articles.jpg' under '/home/username/public_html/images' directory tree
find /home/username/public_html/images -name "articles.jpg"
Enables shell option 'nullglob'.
shopt -s execfail
Find all files/directories owned by the user 'bob' under '/home' directory tree
find /home -user bob
Print file information of command "passwd"
ls -l `which passwd`
Make directories to "directory{1..3}/subdirectory{1..3}/subsubdirectory{1..2}" as needed
mkdir -p directory{1..3}/subdirectory{1..3}/subsubdirectory{1..2}
Find files/directories writable by group or others under the /path directory
find /path -perm /g+w,o+w
create symbolic links in current directory to all files located in "dir" directory and have filename extension "jpg"
find dir -name \*.jpg -print0 | xargs -0 -N1 ln -s
Recursively add read and directory access to all permissions of all files and directories
chmod -R a+rX *
sleep for 10 seconds
sleep 10
Copy "*.cc", "*.h", and "SConstruct" to "rsync://localhost:40001/bledge_ce" using blocking IO
rsync --blocking-io *.cc *.h SConstruct rsync://localhost:40001/bledge_ce
Find the unique owners of all the files in the /bin directory
find /bin -type f -follow | xargs ls -al | awk ' NF==9 { print $3 }'|sort -u
find all the symbolic links in the current folder and follow to the pointing file
find -L
Print content of 'domains.txt' with removed first one of dot-delimited fields
rev domains.txt | cut -d '.' -f 2- | rev
find all the text files in the temp folder and search for the word hello in all these files and display the matched files
find /tmp -type f -name ‘*.txt*’ | sed -e ‘s/.*/\”&\”/’ |xargs -n 1 grep -l hello|sed -e ‘s/.*/\”&\”/’
delete all the core files in the folder /prog which are bigger than 1KB
find /prog -type f -size +1000 -print -name core -exec rm {} \;
Search the current directory tree for files executable by at least someone
find . -type f -perm +111 -print
Run perl -V (displays informations about perl's setup) in an empty environment.
env -i perl -V
Check the environment variables generated by switching to the root account.
sudo env
Find command will list of all files & directories from current directory , before listing echo command will display ' List of files & Directory '
find . -exec echo ' List of files & Direcoty' {} \;
update the permissions of the directories in the folder folder_name to 775
find folder_name -type d -exec chmod 775 ‘{}’ \;
Backup all of the Java files in the current directory tree by copying them and appending the suffix .bk to each
find . -name "*.java" -exec cp {} {}.bk \;
Find all the files in file system which are greater than 50MB and less than 100MB
find / -size +50M -size -100M
Automatically send "y" to "sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm" to automate installation
yes | sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
search for MP3 files in the current folder and subfolders except in dir1 subfolder.
find ! -path "dir1" -iname "*.mp3"
Calculate the md5 sum of all ".py" files in "/your/dir" including content and filenames
grep -ar -e . --include="*.py" /your/dir | md5sum | cut -c-32
Print all logins formatted as "The user USER is on TTY" where USER is the user name and TTY is the login terminal
who | awk '{print "The user " $1 " is on " $2}'
find all files in the current folder whose size is less than 50KB
find . -size -50k
find all text files which have extra extensions in the current folder
find . -name '*.text' -exec sh -c 'for i do if [ ! -f "${i%.text}" ]; then echo == $i; fi;done' sh {} +
Find all files named "foo_bar" in the current directory recursively
find -name foo_bar
Remove all directories called "test" from the current directory tree
find . -name test -type d -exec rm -r {} +
Find all directories under current directory whose paths are 5 characters long
find . -regextype posix-extended -type d -regex ".{5}"
Print the list of directories residing in the current directory tree
find . -type d -exec ls -ld {} \;
List all files/directories under current directory with 'FooBar' in their paths ensuring white space safety
find . -print0 | grep --null 'FooBar' | xargs -0
Find all *.c files located under /home and below
find /home -name "*.c"
Make a new directory "new-dir" in every directory in the current directory tree
find . -type d | xargs -I "{x}" mkdir "{x}"/new-dir
Backup all PHP files under the current directory tree
find -name "*.php" –exec cp {} {}.bak \;
Find all the files in file system which are greater than 50MB and less than 100MB
find / -size +50M -size -100M
Find all SGID set files
find / -perm /g=s
Search for first match of the case insensitive regex 're' in all *.coffee files under current directory
find . -name \*.coffee -exec grep -m1 -i 're' {} \;
Changes to the directory where 'ssh' executable is located.
cd $(dirname $(which ssh));
Find all files in the current directory tree whose size is greater than 1MB
find . -size +1M
Find all files/directories named '.todo' under $STORAGEFOLDER directory tree and print the parent directory names
find "$STORAGEFOLDER" -name .todo -exec dirname {} \;
Find '.git' directories in directory tree /home/madhu/release/workspace
find /home/madhu/release/workspace -type d -name '.git'
Replace any blank character from standard input with a tab
tr '[:blank:]' \\t
Report total size of the root filesystem disk usage in powers of 1000.
df -H --total /
Display all files in a folder
find man5 -print
Set variable BZIP2_CMD to the full path of command "bzip2"
BZIP2_CMD=`which bzip2`
replaces the last occurrence of 'a' with 'c'
tac | sed '0,/a/ s/a/c/' | tac
search for a word in all the php files in the current folder and display the count of all matching lines.
find . -name \*.php -type f -exec grep -Hn '$test' {} \; | wc -l
Find all files/directories in directories/files taken from the glob pattern '/tmp/test/*' that were modified within the last day
find /tmp/test/* -daystart -mtime -1
display all the .sh scripts and perl files in the current folder
find . -type f \
Write standard input to standard output and file "/tmp/arjhaiX4"
tee /tmp/arjhaiX4
Move all *.pdf.marker files and their corresponding *.pdf files under ${INPUT} to ${OUTPUT}
find ${INPUT}/ -name "*.pdf" -exec test -e '{}'.marker \; -exec mv '{}' '{}'.marker ${OUTPUT} \;