nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
find all the files that are modified in the last 1 day | find -mtime +0 -mtime -1 |
Find and remove all .mp3 regular files under the current directory and below | find . -type f -name "*.mp3" -exec rm -f {} \; |
Change to the directory pointed by variable TAG | cd "$TAG" |
Print a colon-separated list of all directories from the ~/code directory tree, except hidden ones and those below them | find ~/code -name '.*' -prune -o -type f -a -perm /u+x -printf ':%h\n' | sort | uniq | tr -d '\n' |
Delete all files in directory $DIR that have not been accessed in at least 5 days | find "$DIR" -type f -atime +5 -exec rm {} \; |
Save the list of .log files in the current directory tree to sas_log_list.txt | find `pwd` -name "*.log" > sas_log_list.txt |
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 a long list of all the jpg files in the home folder | find ~ -iname '*.jpg' -exec ls {} + |
Save the absolute path of the directory of the current script to variable "DIR" | DIR=$(dirname "$") |
List all environment variables containing 'USER' in their name or value that would result in running a command with 'sudo env'. | sudo env |grep USER |
Find all files in the directory $directory or below with the permissions specificed by $permissions. | find "$directory" -perm "$permissions" |
Remove all *.bak files under current directory | find . -type f -name \*.bak -print0 | xargs -0 rm -v |
Print difference between two strings "$s" and "$r" | diff < < | awk '/[<>]/{printf $2}' |
Search the current directory and its sub-directories for any file that has "bsd" somewhere in its name. | find . -name "*bsd*" -print |
Find all *.ext regular files under /path and execute my_cool_script for each of them with the file path as argument | find /path -type f -name '*.ext' -exec my_cool_script \{\} \; |
Find all *.m4a files/directories under /home/family/Music directory | find /home/family/Music -name '*.m4a' -print0 |
Remove all files with a txt extension under current directory | find . -type f -name "*.txt" -print|xargs rm |
find all files ending with "js.compiled" in current folder and rename them. | find . -name "*.js.compiled" -exec rename -v 's/\.compiled$//' {} + |
Search the /Path directory tree for files whose pathnames match "/Path/bar*" or "/Path/foo*" and whose names match pattern "file_name*" | find /Path \ -name "file_name*" |
Search for filenames matching "android" in the current directory and number the output | ls | grep android | nl |
Run command 'su whoami' on host 'remotehost' | echo "su whoami" |ssh remotehost |
login as user username | su - username |
Show a long listing of files not modified in over 20 days or not accessed in over 40 days | find /mydir \ -exec ls -l {} \; |
Creates random file name formatted like expression in variable ${str// /X} and saves it in 'rand_str' variable. | rand_str=$ |
list jobs including its PIDs | jobs -l |
Find directories that are directly under $workspace_ts directory and were modified more than 30 days ago | find $workspace_ts -mindepth 1 -maxdepth 1 -type d -mtime +30 -print |
Finds IP address of default network interface. | netstat -rn | gawk '/UG/ {print $NF}' | xargs ifconfig | gawk 'match($0,/inet addr: B/,a) {print a[1]}' |
Search directories /path/to/directory/folder{1..50} for .txt files, outputting only the names of the matched files | find /path/to/directory/folder{1..50} -name '*.txt' -exec basename {} \; 2>/dev/null |
Run the PHP script "newEmptyPHP" redirecting the output to "nohup.out" in the current directory, or in the home directory if that is not possible. The process will not receive or respond to SIGHUP which are sent to it. | nohup php newEmptyPHP.php & |
ssh into "hostname" as user "buck" | ssh buck@hostname |
find all the files which have been accessed after modifying the file /etc/hosts | find -anewer /etc/hosts |
Make directory "dirname" with permissions set to 777 | mkdir -m 777 dirname |
Unzip "file.gz" and print each line with the 2nd | separated field greater than 5 | zcat a.csv.gz | gawk '$2>5' FPAT='[^"|]+' |
find all the jpg files in current folder and sort them | find . -type f|grep -i "\.jpg$" |sort |
Add executable permission to "rr.sh" | chmod +x rr.sh |
Find all files/directories under current directory and count the number of lines for the output | find |wc -l |
Print second section of space-separated data from text file "a". | cut "-d " -f2 a |
Go to directory /cygdrive/c/Program Files using quotes to escape special characters | cd "/cygdrive/c/Program Files " |
Find all the files in the current directory | find * -type f -print -o -type d -prune |
Search the current directory for files whose names start with "messages." ignoring SVN and CVS files | find \( -name 'messages.*' ! -path "*/.svn/*" ! -path "*/CVS/*" \) -exec grep -Iw uint {} + |
Find all IP addresses in /etc directory files | find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \; |
Find *.c and *.h files under the current directory tree skipping hidden directories and files | find . \ -a -name '*.[ch]' |
Count the number of lines in every regular .rb file in the current directory tree | find . -name "*.rb" -type f -print0 | xargs -0 wc -l |
Find all files with the SUID bit set beginning with the root directory | find / -perm -u+s |
Find all *.php (case insensitive) and *.js files (case insensitive) under /home/jul/here excluding /home/jul/here/exclude/* paths | find /home/jul/here -type f \( -iname "*.php" -o -iname "*.js" \) ! -path "/home/jul/here/exclude/*" |
Sets prompt to "username@host:pwd" | export PS1="\[\033]0;\u $(host $)\007\]\u@\h:\w\$ " |
Print a list of differing files | diff -q /dir1 /dir2|cut -f2 -d' ' |
Search the file system for regular files whose names are shorter than 25 characters | find / -type f | egrep '.*/.{1,24}$' |
Print nothing because 'MYVAR' string doesn`t match with '/[^/]+:' pattern | echo MYVAR | grep -oE '/[^/]+:' | cut -c2- | rev | cut -c2- | rev |
Copies all files under current directory like '*FooBar*' to the '~/foo/bar' directory. | find -name '*FooBar*' -print0 | xargs -0 cp -t ~/foo/bar |
Look for any files that were modified 2-5 days ago | find -mtime +2 -mtime -5 |
Find all *foo files/directories under current directory | find . -name '*foo' |
display all files in the current folder along with their last accessed timestamps | find . -printf "%h/%f : dernier accès le %AA %Ad %AB %AY à %AH:%AM:%AS\n" |
Enables shell option 'progcomp'. | shopt -s progcomp |
Print lines in "file1" that exist in "file2" | join -t " " -j 1 <(sort file1) <(sort file2) |
Read a line from standard input into variable "message" with escaped prompt "Please Enter a Message: \n\b" | read -p "$(echo -e 'Please Enter a Message: \n\b')" message |
Replace all occurrence of "subdomainA.example.com" with "subdomainB.example.com" in all files under the current directory and below | find . -type f -print0 | xargs -0 perl -i.bak -pe 's/subdomainA\.example\.com/subdomainB.example.com/g' |
Move all directories in the current directory that match "some-dir" to "x/" | find ./ -maxdepth 1 -name "some-dir" -type d -print0 | xargs -0r mv -t x/ |
Find the largest files in a particular location | find /home/tecmint/Downloads/ -type f -exec du -Sh {} + | sort -rh | head -n 5 |
Puts the job 1 in the background. | bg %1 [puts the job in the background] |
Display the content of file "f" in home directory if it exists and is executable | cat `which ~/f` |
Find all the files/directories in the current directory tree which have been modified between 2014-08-25 and 2014-08-26 | find ./ -newermt 2014-08-25 ! -newermt 2014-08-26 -print |
find all the files under '/usr/local' directory tree which have been modified exactly 24 hours ago | find /usr/local -mtime 1 |
Check that the master ssh connection "officefirewall" is running | ssh -O check officefirewall |
Write the output of "false" to standard output and to "/dev/null" | false | tee /dev/null |
Find files named tecmint.txt of owner root in the entire file system | find / -user root -name tecmint.txt |
Find all *fink* files/directories in entire file system | find / \ -name \*fink\* -print |
Display differences between file1 and file2 side-by-side. | diff -y file1 file2 |
View history using "more" | history | more |
find all files with pattern` '*song*abc2009*.jpg' and replace "abc2009" with "def2010" | find . -name '*song*abc2009*.jpg' | sed 's/\abc2009\$/mv "&" "\1def2010\2"/' | sh |
Print numbers from 1 to 10 with 2 values per line | seq 10 | sed 'N;s/\n/ /' |
create a symbolic link named "$ORACLE_HOME/include" to file "/usr/include/oracle/11.2/client" | sudo ln -s /usr/include/oracle/11.2/client $ORACLE_HOME/include |
display all the files in the current folder which have been modified in the last 24 hours | find . -mtime -1 -print |
display a long listing of all the java files in the current folder in sorted order | find . -type f -name '*.java' -ls | sort -k +7 -r |
Find files and directories that are at least seven levels of nesting in the directory /usr/src | find /usr/src -name CVS -prune -o -mindepth 7 -print |
find all the configuration files in the files system and donot display any errors. | find / -name "*.conf" 2>>/dev/null |
Find all *~ files/directories under dir and print an rm command for each of them for deletion | find dir -name \*~ | xargs echo rm |
search for a word in all the .C files in the current directory | find . -name "*.c" -exec grep -ir "keyword" {} ";" |
Print the user name of the current user | whoami |
Find all files whose names begin with 'Makefile' at the /usr/ports directory tree's level 3 and count the number of lines with NOPORTDOCS or NOPORTEXAMPLES in them. | find /usr/ports/ -name Makefile\* -mindepth 3 -maxdepth 3 -exec egrep "NOPORTDOCS|NOPORTEXAMPLES" '{}' '+' | wc -l |
Generate the obsolete 29 character Spanish alphabet and number each character | echo -e {{a..c},ch,{d..l},ll,{m,n},ñ,{o..z}}"\n" | nl |
Print 4th white space separated field in file "file" | tr -s ' ' < file | cut -d' ' -f4 |
Search the /myfiles directory tree for files last modified 2 days ago | find /myfiles -mtime 2 |
use regex with find command | find . -regextype sed -regex ".*/[a-f0-9\-]\{36\}\.jpg" |
Print a count of duplicate lines in "filename" sorted by most frequent | sort filename | uniq -c | sort -nr |
Search the current directory tree for the files with extension "trc" and list them if they are more than three days old | find . -name "*.trc" -ctime +3 -exec ls -l {} \; |
Print each line in "file1.txt" that is not found in "file2.txt" | sort file1.txt file2.txt file2.txt | uniq -u |
Find recursively the latest modified file in the current directory | find . -type f -print0|xargs -0 ls -drt|tail -n 1 |
Find and show all files in the current directory tree that are exactly 2000 kB | find . -size 2000k |
Find all *.old files and move them to directory oldfiles | find . -name "*.old" -exec mv {} oldfiles \; |
SSH into host "$1" using key file "/path/to/ssh/secret/key" and execute command "$2" | ssh -i /path/to/ssh/secret/key $1 $2 |
Set the shell option 'errexit' causing bash to exit immediately if one of the commands in a multi-command statement fails. | set -e |
Redirect stderr to stdout and write to the console and "/dev/null" | xxx |& tee /dev/null |
Search only for regular files | find -type f |
Report file system containing /tmp disk usage in kilobytes. | df -k /tmp |
Copy all files below the current directory whose names contain "foobar" (case-insensitive) to directory foo/bar/ in user's home directory. | find . -iname "*foobar*" -exec cp "{}" ~/foo/bar \; |
Save the number of matching executables for "$cmd" in $PATH to variable "candidates" | candidates=$ |
Find all 2*.data files/directories under jcho directory | find jcho -name 2*.data |
Remove adjascent duplicate lines from file 'input' comparing all but last space-separated fields | rev input | uniq -f1 | rev |
Filters only directories from long file listing of a current directory, and prints their names. | ls -l | grep "^d" | awk -F" " '{print $9}' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.