nl
stringlengths
13
387
bash
stringlengths
1
532
Treat each line of "list-of-entries.txt" as a value to be put in one cell of the table that "column" outputs
column list-of-entries.txt
Try to determine the type of contents in "myfile" located in user's home directory.
file ~/myfile
Truncate all non-empty regular files under the current directory
find . -type f -maxdepth 1 -not -empty -print0 | xargs -0i cp /dev/null {}
Turns on network interface eth0.
ifconfig eth0 up
Type unique list of all directories contiaining each file named 'myfile' under the /home directory
find /home/ -name 'myfile' -type f | rev | cut -d "/" -f2- | rev | sort -u
Uncompress "archive.tar.gz" and extract the archive to "/destination"
gzip -dc archive.tar.gz | tar -xf - -C /destination
Uncompress and unarchive "data.tar.gz"
gzip -dc data.tar.gz | tar -xvf -
Unpack all *.gz archives in the current directory tree
find . -name '*.gz' -print0 | xargs -0 gunzip
unsafed rm all file which name start with '#'
find / -name '#*' -atime +7 -print | xargs rm
Unsets 'history' shell option.
shopt -u -o history
Unset the executable bit of all regular files from directory trees arch, etc, lib, module, usr, xpic
find arch etc lib module usr xpic -type f | xargs chmod -x
Unsets shell option 'extglob'.
shopt -u extglob
Unzip "bigfile.txt.gz" to standard output, search for patterns in "patterns.txt", and list the unique matches
gunzip -c bigfile.txt.gz | grep -f patterns.txt | sort | uniq -c
Unzip "daily_backup.sql.gz" and search for lines matching "'x'|/x/"
zcat daily_backup.sql.gz| grep -E "'x'|/x/"
Unzip "file.gz", list the unique first comma separated field prefixed by the number of occurrences, sort from least frequent to most frequent
zcat file.gz | cut -f1 -d, | sort | uniq -c | sort -n
Unzip "file.gz", list the unique lines matching regex pattern '"searchstring":"[^"]*"' prefixed by the number of occurrences, sort from least frequent to most frequent
zcat file.gz | grep -o '"searchstring":"[^"]*"'| sort | uniq -c | sort -n
Unzip "file.gz" to standard output and execute in bash with arguments "-n wordpress"
gzip -d --stdout file.gz | bash -s -- "-n wordpress localhost"
Unzip "file.gz" to stdout
zcat file.gz
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 {} \;
Unzip all ".gz" files in the current directory tree to their respective directories
find . -name "*.gz" -execdir gunzip '{}' \;
Unzip all files matching "/homes/ndeklein/mzml/*.gz"
ls /homes/ndeklein/mzml/*.gz | xargs -I {} gunzip {}
Unzip all files matching "test1/*/*.gz"
gunzip test1/*/*.gz
Unzip all files that match "*.gz" in the current directory and subdirectories to stdout and search for "test"
find . -name "*.gz" -exec zcat "{}" + |grep "test"
Unzip and expand tar archive "compressFileName"
zcat compressFileName | tar xvf -
Unzip and merge all "small-*.gz" files into files of 2000000 lines
zcat small-*.gz | split -d -l2000000 -a 3 - large_
unzip and search for a word in all the jar files in the current folder and display the matched file name
find . -iname '*.jar' -printf "unzip -c %p | grep -q '<stringWithOrWithoutSpacesToFind>' && echo %p\n" | sh
Unzip and untar "4.56_release.tar.gz" to standard output
gunzip -c 4.56_release.tar.gz | tar xvf -
Unzip and untar "file.tar.gz"
zcat file.tar.gz |tar x
Unzip and untar "myarchive.tar.gz" and check for corruption
gunzip -c myarchive.tar.gz | tar -tvf -
Unzip and untar "openssl-fips-2.0.1.tar.gz"
gunzip -c openssl-fips-2.0.1.tar.gz | tar xf ­-
Ungzip and untar all files matching "www-backup.tar.*"
cat www-backup.tar.*|gunzip -c |tar xvf -
Unzip every ".gz" file in the current directory
gunzip *.gz
Unzip every ".gz" file in the current directory tree
find . -name "*.gz" | xargs gunzip
Unzip every ".gz" file in the current directory tree
find . -name '*.gz' -exec gunzip '{}' \;
Update the archive '2009.tar' with the files from the data/ directory tree that match pattern 'filepattern-*2009*'
find data/ -name filepattern-*2009* -exec tar uf 2009.tar {} ;
Update the archive '2009.tar' with the files from the data/ directory tree that match pattern 'filepattern-*2009*'
find data/ -name filepattern-*2009* -print0 | xargs -0 tar uf 2009.tar
Update the archived copy of the home directory, "alldata.tar"
find ~/ -newer alldata.tar -exec tar uvf alldata.tar {} ;
update the permission of all the files in the folder /u/netinst to 500
find /u/netinst -print | xargs chmod 500
update the permission of all the php files in current directory and save the output to a file
find . -name '*.php' -exec chmod 755 {} \; | tee logfile.txt
update the permissions of the directories in the folder folder_name to 775
find folder_name -type d -exec chmod 775 ‘{}’ \;
Update the timestamp of 'filename', or create an empty file if it doesn't exist.
touch filename
Update timestamps of all files and directories under current directory.
find . -print0 | xargs -0 touch
Update timestamps of all files and directories under directory /path/to/dir.
find /path/to/dir -print0 | xargs -0 touch
Update timestamps of all files in entire filesystem which are not newer than /tmp/timestamp
find / ! -newer /tmp/timestamp -exec touch {} \;
Update timestamps of all files (not directories) under current directory.
find . -exec touch {} \;
Update timestamps of all files (not directories) under current directory. Also works on older Unix systems with obsolete 'find' command.
find . -print -exec touch {} \;
Update timestamps of all regular files (ie. excluding directories, symlinks, sockets, etc.) under /your/dir
find /your/dir -type f -exec touch {} +
Use "$BYTES" amount of RAM for "$SECONDS" seconds with no output
cat <(yes | tr \\n x | head -c $BYTES) <(sleep $SECONDS) | grep n
Use "$BYTES" amount of RAM with no output
yes | tr \\n x | head -c $BYTES | grep n
Use "/var/log/wtmp" and print IPs and search for "^msw.*127.0.0.1"
who --ips /var/log/wtmp | grep '^msw.*127.0.0.1'
Use "vagrant-ssh" as the config file and ssh into "default" host
ssh -F vagrant-ssh default
using exec in find command to dispaly the searched files
find . ... -exec cat {} \; -exec echo \;
Use multiple -exec command in find . Find all .txt files & grep banna in .txt files .
find . -name "*.txt" -exec echo {} \; -exec grep banana {} \;
Use the octal form to find and print detailed information about all regular files in your home directory and below that have only the group permission set.
find . -perm 040 -type f -exec ls -l {} \;
use regex with find command
find . * | grep -P "[a-f0-9\-]{36}\.jpg"
use regex with find command
find . -regextype posix-egrep -regex '\./[a-f0-9\-]{36}\.jpg'
use regex with find command
find . -regextype sed -regex ".*/[a-f0-9\-]\{36\}\.jpg"
Variable PID contains a process ID, check if this process exists - resulting exit status from this command will be zero if it does and current user has permission to send it signals.
kill -0 $PID
Verbosely change ownership of "$file" to "root"
chown -v root "$file"
Verbosely compresses all files on fifth and sixth depth level keeping original files in place.
bzip2 -kv */*/*/*/*/*
Verbosely compresses all files on fourth and fifth depth level keeping original files in place.
bzip2 -kv */*/*/*/*
Verbosely compresses all files on sixth and seventh depth level keeping original files in place.
bzip2 -kv */*/*/*/*/*/*
Verbosely compresses all files on third and fourth depth level keeping original files in place.
bzip2 -kv */*/*
Verbosely compresses all files on third and fourth depth level keeping original files in place.
bzip2 -kv */*/*/*
View lines 116 through 120 of history
history | head -n 120 | tail -n 5
View line 500 to line 500 + 501 in gzipped file "bigfile.z"
zcat bigfile.z | tail -n +500 | head -501
View the man page of find
man find
view the manual page of find
man find
Views text content of compressed FileB file in TarFile archive.
tar -xOf TarFile FileB.gz | zless
wait 2 seconds and then print "hello"
echo "hello `sleep 2 &`"
This will remove all files (type f) modified longer than 14 days ago under /root/Maildir/ recursively from there and deeper (mindepth 1
find /root/Maildir/ -mindepth 1 -type f -mtime +14 | xargs rm
Wrap each line in "file" to fit in 80 characters and count the number of lines
fold file | wc -l
Wrap each line in "file.txt" to fit in 80 characters
cat file.txt | fold
Wrap each line in "file.txt" to fit in 80 characters
fold -w 80 file.txt
Wrap each line in "longline" to a maximum of 30 characters
fold -w30 longline
Wrap each line in "longline" to a maximum of 30 characters breaking at spaces
fold -w30 -s longline
Wrap standard input to fit in 10 characters per line
fold -w 10
Write "127.0.0.1 ad.doubleclick.net" to the console and append to "/etc/hosts" as root
echo 127.0.0.1 ad.doubleclick.net | sudo tee -a /etc/hosts
Write "2-1" to standard output and to "/sys/bus/usb/drivers/usb/unbind"
echo '2-1' |sudo tee /sys/bus/usb/drivers/usb/unbind
Write "2-1.1.1" to standard output and to file "/sys/bus/usb/drivers/usb/unbind"
echo '2-1.1.1'|sudo tee /sys/bus/usb/drivers/usb/unbind
Write "Australia/Adelaide" to standard output and to "/etc/timezone"
echo "Australia/Adelaide" | sudo tee /etc/timezone
Write "Hello, world" to standard output and to "/tmp/outfile"
echo "Hello, world" | tee /tmp/outfile
Write "Some console and log file message" to standard output and "/dev/fd/3"
echo "Some console and log file message" | tee /dev/fd/3
Write "[some repository]" to standard output and append to "/etc/apt/sources.list" as root
echo "[some repository]" | sudo tee -a /etc/apt/sources.list
Write "\n/usr/local/boost_1_54_0/stage/lib" to standard output and append to "/etc/ld.so.conf"
echo -e "\n/usr/local/boost_1_54_0/stage/lib" | sudo tee -a /etc/ld.so.conf
Write "deb blah ... blah" to standard output and append to "/etc/apt/sources.list" as root
echo 'deb blah ... blah' | sudo tee --append /etc/apt/sources.list
Write "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" to standard output and append to "/etc/apt/sources.list.d/10gen.list" as root
sudo echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list.d/10gen.list
Write "error" to standard output
echo "error" | tee
Write "fifo forever" infinitely using the named pipe "fifo" by writing its contents to standard output and to "fifo"
echo "fifo forever" | cat - fifo | tee fifo
Write "foo" to the real path of the current command's standard input
echo foo | readlink /proc/self/fd/1
Write "foo" to the real path of the current command's standard output
echo foo | readlink /proc/self/fd/0
Write "hello world" to the console and print number of bytes, symbols and strings in provided input.
echo "hello world" | tee >(wc)
Write "suspend" to standard output and to file "/sys/bus/usb/devices/usb3/power/level"
echo suspend | sudo tee /sys/bus/usb/devices/usb3/power/level
Write '"myname="Test"' to the console and append to "$CONFIG" as root
echo "myname=\"Test\"" | sudo tee --append $CONFIG
Write a random list of numbers to /tmp/lst and stdout.
seq 1 10 | sort -R | tee /tmp/lst |cat <(cat /tmp/lst) <(echo '-------') **...**
Write the common third space separated fields in "file1.sorted" and "file2.sorted" to "common_values.field"
comm -12 <(cut -d " " -f 3 file1.sorted | uniq) <(cut -d " " -f 3 file2.sorted | uniq) > common_values.field
Write contents of "/sys/kernel/debug/tracing/trace_pipe" to standard output and to "tracelog.txt" executing as a root user
sudo cat /sys/kernel/debug/tracing/trace_pipe | tee tracelog.txt
Write the current date and time followed by " 0" to the console and append to "log.csv"
echo $(date) "0" | tee -a log.csv
Write the current date and time followed by " 1" to the console and append to "log.csv"
echo $(date) "1" | tee -a log.csv
Write current directory listing to standard output and to "files.txt"
ls |& tee files.txt