nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Check if a drive with UUID "09b8f1ab-8d4b-4c5f-b395-40be09c090b0" is mounted
|
mount | grep $
|
Search the files in the current directory tree that are named "string to be searched" for "text"
|
find . -name "string to be searched" -exec grep "text" "{}" \;
|
Find and print the names of all files found in the current directory and all of its sub-directories
|
find . -print
|
display all the files in the current directory and do not search in the sub directories
|
find . -maxdepth 0 -print
|
Find all *.txt files/directories under current directory
|
find -name '*.txt'
|
Print the hexadecimal bytes and printable characters of "Hello world"
|
echo Hello world | od -t x1 -t c
|
Find empty regular files in /dir and its subdirectories
|
find /dir -type f -size 0 -print
|
search for the text file "file.txt" and display its parent directory
|
cd /nfs/office/ && find . -name 'file.txt' | sed -r 's|(\./?).*|\1|'
|
Compress all .txt files in the current directory tree to archive "txt.zip"
|
find . -name '*.txt' | xargs zip -9 txt.zip
|
Find all files/directories under $1 which have at least execute permission for their owner and set execute permission for group for these files/directories
|
find $1 -perm -u+x -exec chmod g+x {} \;
|
display all the files in the current folder excluding those which are in the path of ".git"
|
find . ! -path "*.git*" -type f -print
|
Search for regular files of the grooup 'users' in the file system
|
find / -type f -group users
|
Find all regular files in /usr/bin accessed more than 20 days ago
|
find /usr/bin -type f -atime +20
|
display all the files in the current folder
|
find . | awk '{ print "FILE:" $0 }'
|
Format the time string $timestamp according to the format string "%Y-%m-%d %H:%M:%S" and save the output to variable 'CDATE'
|
CDATE=$( date -d @"$timestamp" +"%Y-%m-%d %H:%M:%S" )
|
find all the files in the folder /work which belong to the user "olivier"
|
find /work -user olivier -print
|
show the disk use of all the regular/normal files in the current folder which are bigger than 50MB
|
find . -type f -size +50000k | xargs du -sh
|
Print the first line of each file under the home directory
|
find $HOME/. -name *.txt -exec head -n 1 -v {} \;
|
Join colon-separated information in 3 files LN.txt PH.txt and AD.txt in a cascade fashion: join LN.txt and PH.txt, then join the result with AD.txt
|
join -t':' < < | join -t':' - <
|
display all the files ending with ".user" or beginning with "admin" or ending with ".user.gz" in /var/adm/logs/morelogs/ and excluding all regular files
|
find /var/adm/logs/morelogs/* -type f -prune \( -name "admin.*" -o -name "*.user" -o -name "*.user.gz" \) -print
|
Search for "ifconfig" in the output of "history" and print 5 lines that precede and follow
|
history | grep ifconfig -A5 -B5
|
A no-op on filename with sed
|
sed -i "s/\\\\\n//g" filename
|
find all the files in the folder /usr/bin which have been modified in the last 10 days
|
find /usr/bin -type f -mtime -10
|
Print a space separated list of numbers from 1 to 10 with no trailing new line
|
seq 10 | xargs echo -n
|
Take a file path from standard input and remove it.
|
xargs -I '{}' rm '{}'
|
Show ls's detailed output for all files named "something"
|
find . -name something -exec ls -l {} \;
|
Change directory to the current user's home directory
|
cd /home/`whoami`
|
find regular files under the current directory, whose name ends in .mbox and rename each file, to the same name without .mbox at the end
|
find . -type f -wholename \*.mbox | sed 's/\\.mbox/mv "\1.mbox" "\1"/' | sh
|
Find files/directories that have no owner or group under /path
|
find /path -nouser -or -nogroup
|
Get the disk space used by all *.txt files/directories under /path directory
|
find /path -iname '*.txt' | perl -lane '$sum += -s $_; END {print $sum}'
|
Copy all files in current directory that do not match */not-from-here/* in their paths to /dest
|
find . -type f -not -path '*/not-from-here/*' -exec cp '{}' '/dest/{}' \;
|
Remove the last 3 characters from 987654321, keeping only 987654
|
echo 987654321 | rev | cut -c 4- | rev
|
Unzip all ".gz" files in the current directory tree excluding files containing "dvportgroups", "nsanity", "vcsupport", "viclient", and "vsantraces"
|
find . -name '*.gz' ! -name '*dvportgroups*' ! -name '*nsanity*' ! -name '*vcsupport*' ! -name '*viclient*' ! -name 'vsantraces*' -exec gunzip -vf {} \;
|
display the number of lines in all the header files in the current folder
|
find . -name "*.h" -print | xargs wc -l
|
List all files in the current directory tree that were modified 60 minutes ago
|
find . -mmin 60 | xargs '-rd\n' ls -l
|
Find all *.php files under current directory and change their permission to 640
|
chmod 640 $(find . -name *.php)
|
Move all files in "/path/subfolder" to "/path" without clobbering any destination files
|
find /path/subfolder -maxdepth 1 -type f -name '*' -exec mv -n {} /path \;
|
Set variable GZIP to the full path of command "gzip"
|
GZIP="$(which gzip)"
|
Get the total sizes of all files under current directory
|
find path -type f -printf '%s\n' | awk '{sum += $1} END {print sum}'
|
Find every directory under "0001" and make new directories replacing "0001" with "0002" at the beginning of their names.
|
find 0001 -type d | sed 's/^0001/0002/g' | xargs mkdir
|
Returns the single most recent file in a directory
|
ls -t | head -n1
|
Archive "./htmlguide" to "~/src/" with resolved symbolic links and delete any extraneous files from "~/src/" not found in "./htmlguide"
|
rsync -av --copy-dirlinks --delete ../htmlguide ~/src/
|
Recursively changes group ownership of everything within '/git/our_repos' to 'shared_group'.
|
chgrp -R shared_group /git/our_repos
|
Display users who are currently logged in
|
finger | sed 's/^\ *\ *pts[^A-Z]*\([^.*/\2\t\t\3/'
|
Run script $2 on remote host $1 using interpreter $INTERPRETER with pseudo-terminal allocation
|
cat $2 | grep -v "#" | ssh -t $1 $INTERPRETER
|
Print an octal dump of "file" with named characters, no addresses, and no suppressed duplicate lines with sections starting with "esc", "fs", "gs", or "us"
|
od -a -An -v file | perl -0777ne 's/\n//g,print "$_\n " for /?(?:.)*/gs'
|
Recursively change owner to "$1" and group to "httpd" of all files in the current directory
|
chown -R $1:httpd *
|
Create a ssh key with no passphrase and store it in "outfile".
|
ssh-keygen -f outfile -N ''
|
Execute the first instance of "parallel" found in the PATH, passing it all parameters received by the script/function
|
`which parallel` "$@"
|
Gets IP address of ${NET_IF} network interface.
|
NET_IP=`ifconfig ${NET_IF} | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'`
|
Display non-hidden files in the current directory with the given output format
|
find . -maxdepth 1 -name '[!.]*' -printf 'Name: %16f Size: %6s\n'
|
Changes group ownership of 'myprog' to 'groupb'.
|
chgrp groupb myprog
|
Find all the files in file system which are accessed 50 days back
|
find / -atime 50
|
Go to directory named "~" (not home directory)
|
cd "~"
|
Perform a dry run to recursively copy "test/a" to "test/dest" excluding "test/a/b/c/d"
|
rsync -nvraL test/a test/dest --exclude=a/b/c/d
|
Gives the primary group of $USERNAME.
|
groups $USERNAME | cut -d\ -f 1
|
Recursively list all files on smbfs mounts
|
mount -v | grep smbfs | awk '{print $3}' | xargs ls -lsR
|
Find directories starting from /TBD that were modified more than 1 day ago
|
find /TBD -mtime +1 -type d
|
See the word count of every *.txt file in the home directory
|
find ~/ -name '*.txt' -print0 | xargs -0 wc -w
|
Create a symbolc link in the current directory to "target"
|
ln -s target
|
Gets MAC address of eth0 network interface.
|
ifconfig eth0 | grep -Eoi [:0-9A-F:]{2}\{5}
|
Convert standard input into a dump of octal bytes without the first 8 bytes of address and count the unique results
|
od | cut -b 8- | xargs -n 1 | sort | uniq | wc -l
|
Find all *.txt files under current directory and copy them to ./tmp
|
find . -type f -name '*.txt' | sed 's/'"'"'/\'"'"'/g' | sed 's/.*/"&"/' | xargs -I{} cp -v {} ./tmp/
|
Write "error" to standard output
|
echo "error" | tee
|
Prints Kb size of all top-level files and folders in a current folder in descending order in human readable format.
|
du -ksh * | sort -n -r
|
Find all *.foo files under current directory and print their contents
|
cat `find . -name '*.foo' -print`
|
Find files that are writable by the user, the group, or both under the plsql directory
|
find plsql -type f -perm /220 -exec ls -l {} \; 2>/dev/null
|
find all files in the current folder that have a single letter in their name and have not been modified today
|
find . -name \? -mtime +0
|
Find all files under 'dir' directory with white space safety in their paths and print their md5 sums into file.txt
|
find dir -type f -print0 | xargs -0 md5sum >> file.txt
|
find the path of a specfic video file in the current directory
|
find ./ -name "foo.mp4" -printf "%h\n"
|
Split the sorted and unique lines in files "emails_*.txt" into files with at most 200 lines each with numeric suffixes of length 4
|
sort --unique emails_*.txt | split --numeric-suffixes --lines=200 --suffix-length=4 --verbose
|
Search for files that were accessed less than 5 days ago.
|
find -atime -5
|
Join columns in "file1" and "file2" if their first field matches and format the output as a table
|
awk 'NR==FNR{m[$1]=$2" "$3; next} {print $0, m[$1]}' file2 file1 | column -t
|
Check if "$file" contains DOS line endings
|
od -t x2 -N 1000 $file | cut -c8- | egrep -m1 -q ' 0d| 0d|0d$'
|
Find all directories under current directory and change their permission to 500
|
find . -type d -exec chmod 500 {} \;
|
Removes all files but $1 newest ones from current folder.
|
ls -tp | grep -v '/' | tail -n +"$1" | xargs -I {} rm -- {}
|
Search in the current directory and all sub-directories except ./D and any further sub-directories also named D for the file named hi.dat
|
$ find . \( -name D -prune \) -o -name hi.dat
|
display the contents of all the files ending with ".fq" and perform a control check on this raw sequence of data and display the output to the screen
|
find . -name "*.fq" -exec cat '{}' ';' | fastqc /dev/stdin
|
Find the files in the current directory that match pattern '*.JUKEBOX.*.txt' and move them to folder ./JUKEBOX
|
find . -name '*.JUKEBOX.*.txt' -maxdepth 1 -print0 | xargs -0 -IFILE mv FILE ./JUKEBOX
|
Search for .bam files anywhere in the current directory recursively
|
find . -name "*.bam"
|
find all the files in the current folder which are bigger than 10MB and less than 50MB
|
find . -size +10M -size -50M -print
|
Search the CSS files found in the current directory tree for string "foo"
|
find . -name \*.css -print0 | xargs -0 grep -nH foo
|
Decompress 'file.gz'
|
gzip -d file.gz
|
find all js files under the build direcotry except build/external and build/log directory.
|
find build -not \( -path build/external -prune \) -not \( -path build/blog -prune \) -name \*.js
|
Display the differences between "file1.cf" and "file2.cf" side-by-side with a width of 150 characters
|
diff -y -W 150 file1.cf file2.cf
|
Find only number of hard link & name of files from long list
|
find -type f -iname "*.txt" -exec ls -lrt {} \;|awk -F' ' '{print $1 $2 $9}'
|
Find all user files larger than 5MB
|
find / -size +5000000c 2> /dev/null
|
Mount the directory "/etc" on "/tmp/sarnold/mount_point/"
|
mount -obind /etc /tmp/sarnold/mount_point/
|
create an archive using 7zhelper.sh as a compress program
|
tar -I 7zhelper.sh -cf OUTPUT_FILE.tar.7z paths_to_archive
|
Display all lines containing PROBES in the current kernel's compile-time config file.
|
grep PROBES /boot/config-$
|
Reversibly sorts content of the '${TMP}/${SCRIPT_NAME}.pid' file, comparing human readable numbers in file strings.
|
cat ${TMP}/${SCRIPT_NAME}.pid|sort -rh;
|
Delete files in /var/tmp/stuff and below that have not been modified in over 90 days
|
find /var/tmp/stuff -mtime +90 -exec /bin/rm {} \+
|
Find all files under current directory and write the paths without the leading ./ in the file outputfile
|
find . -type f -printf '%P\n' > outputfile
|
Search for first match of the regex 're' in all *.coffee files under current directory
|
find . -name \*.coffee -exec awk '/re/ {print;exit}' {} \;
|
Find files with a question mark in their names
|
find . -name \*\\?\*
|
Get directory listing of URL $1 and save them to variable 'header' by deleting '\r' characters
|
header="$"
|
show all files in /usr/tom and display only files ending with ".pl" or ".pm"
|
find /usr/tom | egrep '*.pl| *.pm'
|
Interpret backslash sequences and delete whitespace characters in variable $FOO and save the result to variable 'FOO_NO_WHITESPACE'
|
FOO_NO_WHITESPACE="$(echo -e "${FOO}" | tr -d '[[:space:]]')"
|
Search the .log files in the current directory tree for string "The SAS System"
|
find `pwd` -name "*.log" -exec grep "The SAS System" {} \;
|
List all files in the /hometest directory tree whose names are "Trash", and their sizes
|
find /hometest -name Trash -exec ls -s {} \;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.