nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Run "myprogram", pausing for user input at each page. | myprogram|more |
remove top-level domain (.com, .org) from URL's in urllist.txt | rev urllist.txt | cut -d. -f 2- | rev |
Find all instances of first column with unique rest of line, and output a count for each first column that found in unique lines. | sort file | uniq | cut -f1 -d' ' | uniq -c | rev |
Display 12345 backwards | echo 12345 | rev |
Find all files/directories under current directory tree wihout descending into './src/emacs' directory | find . -path './src/emacs' -prune -o -print |
List all files under current directory with white space safety in their paths | find . -type f -print0 | xargs -0 ls |
find files in the current directory having name "filename" | find -iname "filename" |
find all foo.bar files in the entire file system | find / -name foo.bar -print |
Search for 'magic' in all regular files under current directory tree | find . -type f | xargs grep "magic" |
Search the /path/to/dir directory tree for .c files | find /path/to/dir -name \*.c |
find the regular js files which path does not contains '*/test/*' and name does not contains '*-min-*' or '*console*' | find . ! -path "*/test/*" -type f -name "*.js" ! -name "*-min-*" ! -name "*console*" |
Display only line numbers listed in 'file_of_line_numbers" from file 'source'. | sed 's/$/p/' file_of_line_numbers | sed -nf - source |
Find blabla* files under current directory | find . -depth -name "blabla*" -type f | xargs rm -f |
Make directories "tmp/real_dir1" and "tmp/real_dir2" as needed | mkdir -p tmp/real_dir1 tmp/real_dir2 |
Report file systems disk space usage pretty formatted. | df -Ph | column -t |
Assign a name when starting a screen session | screen -S lynx lynx |
Finds strings with text "searched-string" recursively in all files of current folder. | grep -r "searched-string" . |
Find all Makefile's in the current directory tree | find -type f -name "Makefile" |
Set the executable bit for all users on all .sh scripts from directory trees lib, etc, debian | find lib etc debian -name "*.sh" -type f | xargs chmod +x |
Delete all HTML files under tree ~/mydir | find ~/mydir -iname '*.htm' -exec rm {} \; |
Grab the output of "basename" (the last slash-separated section of variable "filename") and echo it to stdout, which basename would do by default anyway. | echo `basename "$filename"` |
Find all the Sticky Bit set files whose permission are 551 | find / -perm 1551 |
Compress all files in directory "$PATH_TO_LOGS" that were last modified more than "$SOME_NUMBER_OF_DAYS" days ago | find $PATH_TO_LOGS -maxdepth 1 -mtime +$SOME_NUMBER_OF_DAYS -exec gzip -N {} \; |
Displays Homebrew’s install path. | brew --prefix |
search for the file test in the current folder | find . -name test |
Convert the contents of 'var1' variable to lowercase | var1=`echo $var1 | tr '[A-Z]' '[a-z]'` |
Print file name without extension assuming there is only one dot in the file name. | echo "$FILE" | cut -d'.' -f1 |
Move each of the directories in /path/to/folders/* to another directory whose name is constituted by appending .mbox to each directory name and create a directory named Messages in this directory then move all *.emlx files into this directory | find /path/to/folders/* -type d -exec mv {} {}.mbox \; -exec mkdir {}.mbox/Messages \; -exec sh -c "mv {}.mbox/*.emlx {}.mbox/Messages" \; |
display all the files in the home folder which are smaller than 500 bytes | find $HOME -size -500b |
Extract the contents of "Input.txt.gz", list the unique first comma separated field prefixed by the number of occurrences | zcat Input.txt.gz | cut -d , -f 1 | sort | uniq -c |
Print newline, word and byte count for all .h, .c, .cpp, .php and .cc files under current directory tree and also show the total counts | wc `find . -name '*.[h|c|cpp|php|cc]'` |
Find all Makefile's in the current directory tree and look for line 235 in each of them | find -type f -name "Makefile" -exec awk 'FNR==235 {print FILENAME; print}' {} + |
start from current directory, skip the directory src/emacs and print it then skip all files and directories under it, and print the names of the other files found | find . -wholename './src/emacs' -prune -print -o -print |
Calculate md5 sum of file ${my_iso_file} and save it to variable 'md5' | md5="$" |
Recursively removes all empty folders under current folder. | find -depth -type d -empty -exec rmdir {} \; |
Find all Perl source code files | find . -name "*.pl" |
Append the contents of ".cwdhist" file to the current in-memory history list | history -r .cwdhist |
Prints calendar for a current month. | cal |
delete all the files ending with "~" in current folder | find -name '*~' -delete |
Make directory "saxon_docs" | mkdir saxon_docs |
Request SSH to run "echo foo; sleep 5; echo bar" in the background | ssh -f user@host "echo foo; sleep 5; echo bar" |
Find all directories under $d directory and set read-write-execute permission for owner and group and no permission for other for those directories | find $d -type d -exec chmod ug=rwx,o= '{}' \; |
Find the .groovy files outside the "./target" directory path | find . -name "*.groovy" -not -path "./target/*" -print |
Archive "source" to "destination" via ssh on port "PORT_NUMBER" | rsync -azP -e "ssh -p PORT_NUMBER" source destination |
Move "$PHANTOM_JS" to "/usr/local/share" directory | sudo mv $PHANTOM_JS /usr/local/share |
Find executable files | find . -perm -100 -print |
login as user postgres | sudo su -l oracle |
Print the user name of the current user | whoami |
Remove duplicates in variable "variable" and preserve the order | variable=$(echo "$variable" | tr ' ' '\n' | nl | sort -u -k2 | sort -n | cut -f2-) |
Find all *.jpg files under current directory | find . -name *.jpg |
create a md5sum for all the instances of the file MyCProgram.c in current folder | find -iname "MyCProgram.c" -exec md5sum {} \; |
Print the names of all the files from directory tree ~/some/directory whose names end in "rb" | find ~/some/directory -name "*rb" -exec basename {} \; |
Set timestamp of all PHP files in current directory to date specified. | touch -d '30 August 2013' *.php |
Search for files containing string "PENDWIDTH" and view the result using the more command | find . -exec grep PENWIDTH {} \; | more |
Find all files/directories under /path/to/files/* paths and print the timestamp in YmdHMS format along with their paths and object of symlinks, stat them and apply the sed replacement "s/\-\- \:\:.*/\1\2\3\4\5\6\7/g" on the output | find /path/to/files/* -printf "%TY%Tm%Td%TH%TM%TS|%p|%l" -exec stat -Lc "|%y" {} \; | sed -r "s/\-\- \:\:.*/\1\2\3\4\5\6\7/g" |
Print continuous lines of 100 random characters either "." or " " | cat /dev/urandom | tr -dc '. ' | fold -w 100 |
Print joined strings from 'file', using space symbol as separator. | cat file | xargs |
search for the word "nutshell" or "Nutshell" in all the files in the folder book | find /book -print | xargs grep '[Nn] utshell' |
Find all files/directories following symlinks under /path/to/dir/* paths and print the timestamp in YmdHMS format along with their paths | find -L /path/to/dir/* -printf "%TY%Tm%Td%TH%TM%TS|%p\n" |
split file input.txt into pieces per 1 line named output.NNNNN | split --lines=1 --suffix-length=5 input.txt output. |
Find all *.rb (regular) files under current directory and change their mode to 600 | find . -name "*.rb" -type f -exec chmod 600 {} \; |
Find all the files in entire file system with the extensions txt or doc, as well as any file larger than 5MB in size | find / \ |
If first command fails, exits from script with exit code of failed command. | make || exit $? |
Recursively lists all files in a current folder in long format. | ls -ld $(find .) |
Find files that do not have a listing in the /etc/passwd or /etc/group in the file system | find / -nouser -o -nogroup |
Find all files/directories under current directory and put the output into full_backup_dir variable | full_backup_dir="`find . -depth -print0`" |
Find all directories named "D" in the current directory tree and print their parents | find ./ -type d -name 'D'|sed 's/D$//' |
Search /var/log for logs larger than 10 megabytes | find /var/log -size +10M -ls |
Saves hostname that matches ${ip_address} in 'host' variable, without trailing dot. | host=$ |
Find all files files under the current directory except *.txt | find . -maxdepth 1 -type f -not -regex '.*\.txt' |
find all the links in the directory students and print them. Do not display any errors. | find /students -type l -print 2> /dev/null |
Display an amount of processes running with a certain name | ab=`ps -ef | grep -v grep | grep -wc processname` |
Delete all regular files with '.txt' extension that were modified in more than 25 minutes ago in maximum 1 level down the directory '/home/u20806/public_html' | find /home/u20806/public_html -daystart -maxdepth 1 -mmin +25 -type f -name "*.txt" \ -exec rm -f {} \; |
Remove the path $1 from the PATH environment variable | PATH=$ |
Find all files and directories starting from the current directory | find . |
search for all the directories in a folder and limit the search to current folder and give them as input to the python script | find /stuff -maxdepth 1 -type d -exec script.py {} + |
Find all *.[ch] files under current directory | find . -name '*.[ch]' |
List all regular files from the current directory tree that were modified less than 60 days ago | find -type f -mtime -60 |
Find all files/directories named 'photo.jpg' under current directory tree | find . -iname "photo.jpg" |
Print all files containing "word1" and "word2" in the current directory tree | comm -12 < < |
Find all regular files whose names contain a case insensitive pattern composed of space separated positional arguments and display a long listing of them | find . -type f -iname '*'"$*"'*' -ls |
Print file system disk space usage | df |
Find users whose names begin with "ab" or whose terminal from which they are logged in ends with "1" | who | grep -e '^ab' -e '1$' |
Opens menu item 'Basic Shell Features' -> 'Shell Expansions' -> 'Filename Expansion' -> 'Pattern Matching' in the 'bash' manual. | info bash 'Basic Shell Features' 'Shell Expansions' 'Filename Expansion' 'Pattern Matching' |
Unsets environment variable 'z'. | unset z |
Prints a process tree for each process of user 'username'. | ps -aux | grep ^username | awk '{print $2}' | xargs pstree |
Forward port 12345 bound on 'localhost' to port 12345 on 'otherHost' as user 'otherUser' | ssh -f -N -L localhost:12345:otherHost:12345 otherUser@otherHost |
Search the /tmp/ directory recursively for files matching regular expression ".*file[0-9]+$" | find /tmp -regex ".*file[0-9]+$" |
Force create a symbolc link named "/usr/local/bin/fpdf" to "/usr/local/bin/findpdftext" | sudo ln -s -f "/usr/local/bin/findpdftext" "/usr/local/bin/fpdf" |
Write the output of "./program" to the console and "a.txt" | ./program | tee a.txt |
display all the regular files in the current folder excluding those that are present in the path "git" | find . -path "*.git*" -prune -o -type f -print |
Print the list of regular files from the current directory tree that were modified less than 2 days ago | find . -type f -mtime -2 -exec echo {} + |
change the permissions of all regular/normal files in the file system | chmod 640 `find ./ -type f -print` |
display all the files in the current folder along with the hidden files with the depth | find . — name "*" — print -о -name ".*" — print -depth |
Archive "/my/dir" on host "server" as user "user" to the current local directory excluding files ending in ".svn" | rsync -av --exclude '*.svn' user@server:/my/dir . |
Compare each file in "repos1/" and "repos2/", treat absent files as empty, ignore differences in whitespace and tab expansions, and print 3 lines of unified context | diff -ENwbur repos1/ repos2/ |
Find all the files under /etc directory which are larger than 100k | find /etc -size +100k |
Search for environmental variables with "HIST" in their name or contents | set | grep HIST |
Counts lines in each *.php file, sorted by number of lines, descending. | find . -name '*.php' -type f | xargs wc -l | sort -nr |
Search for the regex '^ERROR' in all *.log files under current directory | find . -name "*.log" -exec egrep -l '^ERROR' {} \; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.