nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Exit the shell immediately if an error is encountered, treat references to unset variables as errors, disable overwriting existing files, and use the first non-zero exit code of a set of piped commands as the exit code of the full set of commands
|
set -o errexit -o nounset -o noclobber -o pipefail
|
set alias "current" for command 'cd $'
|
alias current='cd $'
|
Print a sorted list of the extensions of the regular files from the current directory tree matching pattern '*.???'
|
find . -type f -name "*.???" | awk -F. '{print $NF}' | sort -u
|
Find all files/directories that are owned by user 'wnj' and are newer than 'ttt' by modification time in the entire filesystem
|
find / -newer ttt -user wnj -print
|
Find all files/directories under current directory and sort them
|
find | sort
|
Prints file descriptor of executed built-in 'true'.
|
echo <(true)
|
Search directory trees /tmp and /var/tmp for "testfile.txt"
|
find /tmp /var/tmp -iname "testfile.txt"
|
List files in directory "one" that exist in directory "two"
|
sort <(ls one) <(ls two) | uniq -d
|
Remove all files and directories called "test" from the current directory tree
|
find . -name test -delete
|
find all the files ending with jpg in current folder and display their count ( case insensitive )
|
find ./ -type f -regex ".*\.[Jj][Pp][gG]$" | wc -l
|
Print the last space separated word from "Your string here"
|
echo "Your string here"| tr ' ' '\n' | tail -n1
|
Extract tar.gz archive and go into the directory that would normally be created by extracting it.
|
tar xvf "$myarchive" && cd "${myarchive%.tar.gz}"
|
Print a welcome message with the current user's user name
|
echo -ne "Welcome `whoami`!\n"
|
Finds strings like "texthere" recursively in all files of a current folder regarding all symlinks.
|
grep -R "texthere" *
|
find all files in home folder which have been modified after a timestamp
|
find ~ -newer /tmp/timestamp
|
find all the files in the current folder which have been modified in the last one minute
|
find . -type f -mmin 0
|
find all the files in the current directory and sub-directories, that were edited within the last 1 hour and execute the list command with long listing format
|
find -mmin -60 -exec ls -l {} \;
|
Search the current directory tree for files and directories whose names do not end in ".exe" and ".dll"
|
find . -not -name "*.exe" -not -name "*.dll"
|
For each line of the sorted output of both file1 and file2, print lines whose first field of file2 does not appear as first field of file1.
|
join -v1 < <
|
Change the owner to "hduser" and group to "hadoop" of "{directory path}"
|
sudo chown hduser:hadoop {directory path}
|
Find any hidden regular files in the current directory and its sub-directories that were modified after .cshrc was last modified.
|
find . -type f -name ".*" -newer .cshrc -print
|
Find files that are writable by both the “other” and the group under the plsql directory
|
find plsql -type f -perm -ug=rw -exec ls -l {} \; 2>/dev/null
|
Calculate the md5sum of the executable file of command "gcc"
|
md5sum $(which gcc)
|
Finds PIDs of all running processes, gets executable binary of each process, and prints containing folder of each binary.
|
ps -A -o pid | xargs -I pid readlink "/proc/pid/exe" | xargs -I file dirname "file"
|
find the oldest normal file in the current directory
|
find -type f -printf '%T+ %p\n' | sort | head -n 1
|
Print linux group names on multiple lines instead of single line output
|
groups | tr \ \\n
|
Print the time to ping "8.8.8.8" followed by a time stamp if the ping is greater than 58
|
ping 8.8.8.8 | awk '{split;if print a[2], strftime}'
|
Display a long list of all the files/directories named ".todo" under $STORAGEFOLDER directory tree
|
find $STORAGEFOLDER -name .todo -exec ls -l {} \;
|
find all the files in the current folder which do not have the execute permission
|
find . -type d ! -perm -111
|
create directory dirname with permissions 777
|
mkdir -m 777 dirname
|
find files having the extension "bam" in current directory
|
find . -name "*.bam"
|
Find the file in the current directory tree with inode number $inum and delete it
|
find . -inum $inum -exec rm {} \;
|
Display differences between /destination/dir/1 and /destination/dir/2 excluding XML files.
|
diff /destination/dir/1 /destination/dir/2 -r -x *.xml
|
Calculate the md5sum of the executable file of command "gcc"
|
md5sum $
|
Find all executable upvoter-* files/symlinks under maximum 1 level down the {} directory
|
find {} -name 'upvoter-*' \( -type f -or -type l \) -maxdepth 1 -perm +111
|
Execute "myfile" on all .ogv files from the current directory tree
|
find ./ -name *.ogv -exec bash -c 'myfile {}' \;
|
search for the directory "config" in the current folder and change directory to it
|
cd `find . -name "config"`
|
Make directory "/etc/cron.15sec"
|
mkdir /etc/cron.15sec
|
List detailed information about all Jar files in the current directory tree
|
find . -name "*.jar" -exec zipinfo {} \;
|
Read a line from standard input into the first argument ("$1") using an interactive shell with prompt "> "
|
read -e -p '> ' $1
|
Find all regular *.css files
|
find . -type f -name "*.css"
|
Find all files/directories under current directory tree with inode number 211028 and move them to 'newname.dir'
|
find . -inum 211028 -exec mv {} newname.dir \;
|
find all the cpp files in the current folder and move them to another folder
|
find . -type f -iname '*.cpp' -exec mv {} ./test/ \;
|
Display the number of sub-directories for all directories under current directory tree, sort them according to the decreasing order of the number and show only the first 10 of them
|
find . -type d -ls | awk '{print $4 - 2, $NF}' | sort -rn | head
|
Replace the occurrences of "HOGE" with "MOGA" once per each line of the .yaml files from the current directory tree
|
find . -type f -name "*.yaml" -print0 | xargs -0 sed -i -e "s/HOGE/MOGA/"
|
Delete current cron job list, and use those in yourFile.text
|
crontab yourFile.text
|
Find regular files readable by the world
|
find . -perm -g=r -type f -exec ls -l {} \;
|
Recursively finds all '*.pdf' files in a current folder and removes them without prompting.
|
find . -name '*.pdf' -exec rm -f {} \;
|
Find files/directories under current directory without descending into it
|
find -prune
|
Find all directories under current directory and set read-write-execute permission for owner, read-execute permission for group and execute permission for other for those directories
|
find . -type d -exec chmod u=rwx,g=rx,o=x {} \;
|
List .html files in the current directory tree that contain string "base\-maps" but do NOT contain string "base\-maps\-bot"
|
find . -name "*.html" -exec grep -lR 'base\-maps' {} \; | xargs grep -L 'base\-maps\-bot'
|
find all the files in the current folder with the name "test-a" and move them to the folder test-10
|
find ~ -type f -name test-a -exec mv {} test-10 \;
|
Print the list of files and directories of the /etc directory
|
find /etc/. ! -name /etc/.
|
Print the /proc directory tree, ignoring the PID-process things
|
find /proc -type d | egrep -v '/proc/[0-9]*' | less
|
Find files/directories with exactly read,write and execute permission for all under /path
|
find /path -perm 777
|
Find a single file called FindCommandExamples.txt under current directory and remove it
|
find . -type f -name "FindCommandExamples.txt" -exec rm -f {} \;
|
get the root user access
|
sudo su
|
Find the passwd file under root and one level down.
|
find -maxdepth 2 -name passwd
|
find all directories with the name test in a directory
|
find /home/john -type d -name test -print
|
Find recursively the latest modified .zip file in the current directory
|
find . -name "*zip" -type f | xargs ls -ltr | tail -1
|
find all the files in the current folder which have execute permission to all the users
|
find . -perm /u=x,g=x,o=x
|
Find all files with name "file.ext" under the current working directory tree and print each full path directory name
|
find `pwd` -name file.ext |xargs -l1 dirname
|
Remove all directories called "test" from the current directory tree
|
find . -name test -type d -print0|xargs -0 rm -r --
|
find all text files in user/directory/ which have been modified today and display the last line of these files
|
find /user/directory/ -name "*txt" -mtime 0 -type f -printf '%p: ' -exec tail -1 {} \;
|
search for al cpp files in current folder and replace all expect the parent directory name of these files and display it them sorted order
|
find . -name '*.cpp' | sed -e 's/\/[^/]*$//' | sort | uniq
|
find all the files that have been modified exactly 24 hours ago
|
find . -type f -mtime 1
|
display all the files in the folder "$ORIG_DIR"
|
find "$ORIG_DIR"
|
Search the current directory recursively for regular files that have been changed less than 3 days ago and print 5 of them.
|
find . -type f -ctime -3 | tail -n 5
|
Use "$BYTES" amount of RAM with no output
|
yes | tr \\n x | head -c $BYTES | grep n
|
Set variable PacketLoss to first digit of percentage of packet loss occurring when pinging host specified by TestIP
|
PacketLoss=$
|
display all the text files in the current folder and do not search in the bin directory
|
find . -name bin -prune -o -name "*.txt" -print
|
View the bash manpage, starting with the view positioned at the first occurrence of the expression "BASH_SOURCE".
|
man bash | less -p BASH_SOURCE
|
Print A record for domain 'domain.' from 'ns2.newnameserver' nameserver
|
dig @ns2.newnameserver domain. a
|
Print a colon-separated list of all directories from the $root directory tree
|
find $root -type d | tr '\n' ':'
|
Modify and rewrite 'file' replacing the first instance of "foo" on each line with "bar"
|
sed -i 's/foo/bar/' file
|
delete all the normal/regular files in the current folder
|
find . -type f -print -delete
|
Copy all files under director 'foo' whose name doesn't contain 'Music' to directory 'bar'.
|
find foo -type f ! -name '*Music*' -exec cp {} bar \;
|
Finds if environment variable like 'DUALCASE' exists in environment.
|
env | grep DUALCASE
|
Change ownership of "/data/db" to the current user
|
sudo chown `whoami` /data/db
|
Change the owner of all ".txt" files in directory tree "/mydir" to "root"
|
find /mydir -type f -name "*.txt" -execdir chown root {} ';'
|
Print out all files with their paths that have identical content and the same filename in different cases
|
find * -type f | xargs md5sum | sort | uniq -Dw32 | awk -F'[ /]' '{ print $NF }' | sort -f | uniq -Di
|
Print the $N'th line from file by replacing commas (',') with newlines
|
head -$N file | tail -1 | tr ',' '\n'
|
Print a top 20 histogram of characters used from standard input showing backslash escapes for non-displayables
|
od -cvAnone -w1 | sort -b | uniq -c | sort -rn | head -n 20
|
Remove Mac OS X Desktop Services Store files
|
find . -name ".DS_Store" -exec rm {} \;
|
recursively change owner of the directory /usr/lib/node_modules/ to the current user
|
sudo chown -R $ /usr/lib/node_modules/
|
Remove all text files in the home directory with confirmation
|
find $HOME/. -name *.txt -ok rm {} \;
|
Print the names of all hidden regular files from the current directory
|
find . -maxdepth 1 -type f -name '.*' -exec basename {} \;
|
Find all files in and below the home directory that have been modified in the last 90 minutes
|
find ~ -mmin -90
|
Find all directories in entire file system which are larger than 50KB
|
find / -type d -size +50k
|
Move all files from the current directory to "targetdirectory"
|
find . ! -name . -prune -exec sh -c 'mv "$@" targetdirectory/' sh {} +
|
Show the number of regular files in the current directory tree
|
find . -type f | wc -l
|
Print the absolute path of third-level files under the current directory tree and number the output
|
ls -d -1 $PWD/**/*/* | nl
|
Find all Lemon*.mp3 files under current directory and run mplayer with these files
|
find . -name 'Lemon*.mp3' -print0 | xargs -0 -i mplayer '{}'
|
Find all the files which are accessed in last 1 hour in entire file system
|
find / -amin -60
|
Print the current directory tree
|
tree
|
create directories mnt and point
|
mkdir mnt point
|
List each unique case insensitive character in "file" prefixed by number of occurrences and sorted from most frequent to least frequent
|
grep -o . filename | tr '[:upper:]' '[:lower:]' | sort | uniq -c | sort -nr
|
Print and save the ping results of 25 requests to "google.com" in "/home/user/myLogFile.log" containing at most 100000 bytes
|
ping -c 25 google.com | tee >
|
Print out ln commands for each file in /home/folder1/*.txt that can be run to create symlinks appending '_CUSTOM_TEXT.txt' in their names
|
find /home/folder1/*.txt -type f | awk -F '.txt' '{printf "ln -s %s %s_CUSTOM_TEXT.txt\n", $0, $1}'
|
update the permissions of the directories in the folder folder_name to 775
|
find folder_name -type d -exec chmod 775 ‘{}’ \;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.