nl
stringlengths
13
387
bash
stringlengths
1
532
Creates full path with parents, that matches to folder path extracted from $f variable.
mkdir -p -- "$(dirname -- "$f")"
Create intermediate directories "tmp" as required and directories real_dir1 and real_dir2
mkdir -p tmp/real_dir1 tmp/real_dir2
Create intermediate directories "x" and "p" as required and create "q"
mkdir -p x/p/q
Create intermediate directories as required
mkdir -p $2
Create intermediate directories as required and directory /tmp/test/blah/oops/something
mkdir -p /tmp/test/blah/oops/something
Create intermediate directories foo and bar as required and directory foo/bar/baz
mkdir -p foo/bar/baz
Create intermediate directoriy path2 as required and directories a..z
mkdir -p path2/{a..z}
Create intermediate directories ~/foo/bar/ as required and directories baz, bif, bang
mkdir -p ~/foo/bar/baz ~/foo/bar/bif ~/foo/boo/bang
Create links for all files in the current directory tree that are more than 1000 days old in "/home/user/archives"
find . -type f -mtime +1000 -print0 | cpio -dumpl0 /home/user/archives
Create master SSH control socket "my-ctrl-socket" in the background with no terminal or command execution with connection forwarding from localhost port 50000 to localhost port 3306 via "jm@sampledomani.com"
ssh -M -S my-ctrl-socket -fnNT -L 50000:localhost:3306 jm@sampledomain.com
Create new crontab set including $job and only jobs from current crontab that don`t contain $command
cat <(fgrep -i -v "$command" <(crontab -l)) <(echo "$job") | crontab -
Creates random file name formatted like expression in variable ${str// /X} and saves it in 'rand_str' variable.
rand_str=$(mktemp --dry-run ${str// /X})
Create ssh tunnel through "genja.org" connecting localhost port 4444 to "raptor.lan" port 22
ssh -L 4444:raptor.lan:22 genja.org
Create symbolic link "$1/link" to the absolute path of "$2"
ln -s "$(readlink -e "$2")" "$1/link"
Create symbolic links in the current directory for all files excluding "CONFIGFILE" located in "/your/project"
find /your/project -maxdepth 1 ! -name "CONFIGFILE" -exec ln -s \{\} ./ \;
Create symbolic links in the current directory for all files excluding "CONFIGFILE" located under "/your/project" directory tree
find /your/project -type f ! -name 'CONFIGFILE' -exec ln -s \{\} ./ \;
Create symbolic links in current directory for all files located in "dir" directory and have filename extension "jpg"
find dir -name '*.jpg' -exec ln -s "{}" \;
Create symbolic links in the current directory for all files located in directory "/path/with/files" with a name containing "txt"
find /path/with/files -type f -name "*txt*" -exec ln -s {} . ';'
Create symbolic links in the current directory for all files under "bar1" that are not directories and do not end in ".cc"
find bar1 -name '*foo*' -not -type d -not -name '*.cc' -exec ln -s $PWD/'{}' bar2/ \;
create symbolic links in current directory to all files located in directory "/original" and have filename extension ".processname"
find /original -name '*.processme' -exec echo ln -s '{}' . \;
create symbolic links in current directory to all files located in directory "/original" and have filename extension ".processname"
ln -s $(echo /original/*.processme) .
create symbolic links in directory "/your/dest/dir/" to all files located in "/your/source/dir/" and have filename extension "txt.mrg"
find /your/source/dir/ -iname '*.txt.mrg' -exec ln -s '{}' /your/dest/dir/ \;
Create symlinks to all /home/folder1/*.txt files and 'folder2_' directory with the same name in a target directory named '+'
find /home/folder1/*.txt -type f -exec ln -s {} "folder2_" + \;
Create symlinks to all /home/folder1/*.txt files with the same name in current directory
find /home/folder1/*.txt -type f -exec ln -s {} \;
Create symlinks to all /home/folder2/*.txt files with the same name in current directory
find /home/folder2/*.txt -type f -exec ln -s {} \;
Create tar.gz files older than one day logs
find /home/testuser/log/ -mtime +1 | xargs tar -czvPf /opt/older_log_$(date +%F).tar.gz
Creates temporary directory in '/tmp/' folder and saves path to it in 'my_tmp_dir' variable.
my_tmp_dir=$(mktemp -d --tmpdir=/tmp)
Creates temporary directory with name formatted like .daemonXXXXXXX in /tmp/ folder, and saves path to it in 'TMPDIR' variable.
TMPDIR=$(mktemp -p /tmp -d .daemonXXXXXXX)
Creates temporary file and saves path to it in 'content_dir1' variable.
content_dir1=$(mktemp)
Creates temporary file and saves path to it in 'content_dir2' variable.
content_dir2=$(mktemp)
Creates temporary file and saves path to it in a 'tmpfile' variable.
tmpfile=$(mktemp)
Creates temporary file and saves path to it in a 'tmpfile' variable.
tmpfile=`mktemp`
Creates temporary file by template provided in option '-t'.
mktemp -t identifier.XXXXXXXXXX
Creates temporary file in $appdir variable with name formatted like expression in variable ${template}, and saves path to it in 'launcherfile' variable.
launcherfile=$(mktemp -p "$appdir" "$template")
Creates temporary file in a current folder and saves path to it in 'f' variable.
f=`mktemp -p .`
Creates temporary file in a current folder with name formatted like 'templateXXXXXX', and saves path to it in 'tempfile' variable.
tempfile=$(mktemp $(pwd)/templateXXXXXX)
Creates temporary file in a TMPDIR folder or /tmp folder if TMPDIR doesn`t defined, with file name like current shell name and '-XXXXX'-formatted suffix, and saves created path to the 'tempFile' variable.
tempFile="$(mktemp "${TMPDIR:-/tmp/}$(basename "$0")-XXXXX")"
Creates temporary file in default folder and saves path to it in 'source' variable.
source=`mktemp`
Creates temporary file in TMPDIR folder or /tmp/ if TMPDIR is not defined, named by template ${tempname}.XXXXXX, and saves path to new file in a TMPPS_PREFIX variable.
TMPPS_PREFIX=$(mktemp "${TMPDIR:-/tmp/}${tempname}.XXXXXX")
Creates temporary file name and saves path to it in 'TMP_FILE' variable.
TMP_FILE="$(mktemp -t)"
Creates temporary file with appended suffix '.cmd' and saves path to it in 'LGT_TEMP_FILE' variable.
LGT_TEMP_FILE="$(mktemp --suffix .cmd)"
Creates temporary file with name formatted like '.script.XXXXXX' in '/tmp/' folder and saves path to it in 'script1' variable.
script1=`mktemp /tmp/.script.XXXXXX`;
Creates temporary file with name formatted like '.script.XXXXXX' in '/tmp/' folder and saves path to it in 'script2' variable.
script2=`mktemp /tmp/.script.XXXXXX`;
Creates temporary file with name formatted like 'emacs-manager.XXXXXX' in '/tmp/' folder and saves path to it in 'tmp_file' variable.
tmp_file=`mktemp --tmpdir=/tmp emacs-manager.XXXXXX`
Creates temporary file with name formatted like expression in variable ${PROG}, and saves path to it in 'mytemp' variable.
mytemp="$(mktemp -t "${PROG}")"
Creates temporary folder, and saves current folder path joined with created temporary folder path in 'tdir' variable.
tdir="$(pwd)/$(mktemp -d)"
Creates temporary folder and saves path to it in 'other' variable.
other="$(mktemp --directory)"
Creates temporary folder and saves path to it in 'td' variable.
td=$( mktemp -d )
Creates temporary folder and saves path to it in a 'tempd' variable.
tempd=`mktemp -d`
Creates temporary folder and save path to that in a TMPDIR variable.
TMPDIR=$(mktemp -d)
Creates temporary folder in /tmp/ (by default) with 10-letter suffux.
mktemp -d -t
Creates temporary folder in a TMPDIR folder or /tmp folder if TMPDIR doesn`t defined, with folder name like current shell name and 10-letter suffix, and saves created path in 'mydir' variable.
mydir=$(mktemp -d "${TMPDIR:-/tmp/}$(basename $0).XXXXXXXXXXXX")
Creates temporary folder in TMPDIR (if defined) or in '/tmp/', and stores path to created folder in 'dir' variable.
dir=$(mktemp -d)
Creates temporary folder in TMPDIR (if defined) or in '/tmp/', and stores path to created folder in 'tmpdir' variable.
tmpdir=$(mktemp -d)
Creates temporary folder like '/tmp/tardir-XXXXXX' with 6-letter suffix and saves its path in 'tmpdir' variable.
tmpdir=$(mktemp -d /tmp/tardir-XXXXXX)
Creates temporary folder relative to directory '/path/to/dir'.
mktemp -d -p /path/to/dir
Creates temporary folder within a $mnt_dir folder and saves path to it in a 'rsync_src' variable.
rsync_src=`mktemp -d -p $mnt_dir`
Creates temporary folder within TMPDIR, with name like current shell name and 10-letter suffix.
mktemp -dt "$(basename $0).XXXXXXXXXX"
Cut off three last symbols from string '1234567890 *'
echo '1234567890 *' | rev | cut -c 4- | rev
Cuts off last part from the path $dir, and deletes resulted folder if empty.
rmdir "$(dirname $dir)"
Decompress "/file/address/file.tar.gz" to standard output
gzip -dc /file/address/file.tar.gz
Decompress "path/to/test/file.gz" to standard output and save all lines matching "my regex" and not matching "other regex" to files with a 1000000 line limit
gzip -dc path/to/test/file.gz | grep -P 'my regex' | grep -vP 'other regex' | split -dl1000000 - file
Decompress "path/to/test/file.gz" to standard output and save all lines matching "my regex" to files with a 1000000 line limit
gzip -dc path/to/test/file.gz | grep -P --regexp='my regex' | split -dl1000000 - file
Decompress "path/to/test/file.gz" to standard output and save all lines matching "my regex" to files with a 1000000 line limit
gzip -dc path/to/test/file.gz | grep -P --regexp='my regex' | split -l1000000
Decompress ${set1[@]} files with gzip
gzip -d ${set1[@]} &
Decompress 'file.gz'
gzip -d file.gz
Decompress 'file.gz' to standard output and execute the output in bash
gzip -d --stdout file.gz | bash
Decompress and unarchive "hello-0.2.tar.gz"
gzip -dc hello-0.2.tar.gz | tar -xf -
Decompress and extract '/usr/src/redhat/SOURCES/source-one.tar.gz'
gzip -dc /usr/src/redhat/SOURCES/source-one.tar.gz | tar -xvvf -
Decompress and extract 'archive.tar.gz' into '/destination'
gzip -dc archive.tar.gz | tar -xf - -C /destination
Decompress and sort "$part0" and "$part1" of files in different processes
sort -m <(zcat $part0 | sort) <(zcat $part1 | sort)
Decompresses each of "*bz2" files under the current folder, redirecting output to the standard out, and prints only fourth of comma-separated fields.
find . -name "*.bz2" -print0 | xargs -I{} -0 bzip2 -dc {} | cut -f, -d4
Decompresses file.
bzip2 -d /tmp/itunes20140618.tbz
Decompresses file 'xac.bz2', redirecting output to standard out.
bzip2 -dc xac.bz2
delete a hard link and create a symbolic link to file named "$link"
ln -sf "$(readlink -f "$link")" "$link"
Delete all ".DS_Store" files/directories under test directory
find test -name ".DS_Store" -delete
delete all the ".bak" or swap files in kat folder
find kat -type f \( -name "*~" -p -name "*.bak" \) -delete
Delete all '-' character from $1 and save the resultant string to variable 'COLUMN'
COLUMN=`echo $1 | tr -d -`
Delete all 'restore.php' files in /var/www and 3 levels below
find /var/www -maxdepth 4 -name 'restore.php' -exec rm -r {} \;
Delete all *txt files under current directory
find . -name "*txt" -type f -print | xargs rm
Delete all .bam files in the current directory tree
find . -name "*.bam" | xargs rm
Delete all the .c files present in the current directory and below
find . -name "*.c" | xargs rm -f
Delete all .pyc files in the current directory tree
find . -name "*.pyc" | xargs -0 rm -rf
Delete all .pyc files in the current directory tree
find . -name "*.pyc" | xargs rm -rf
Delete all .svn files/directories under current directory
find . -depth -name .svn -exec rm -fr {} \;
Delete all .svn files/directories under current directory
find . -name .svn -delete
Delete all .svn files/directories under current directory
find . -name .svn -exec rm -rf '{}' \;
Delete all .svn files/directories under current directory
find . -name .svn -exec rm -rf {} +
Delete all .svn files/directories under current directory
find . -name .svn -exec rm -rf {} \;
Delete all .svn files/directories under current directory
find . -name .svn -exec rm -v {} \;
Delete all .svn files/directories under current directory
find . -name .svn | xargs rm -fr
Delete all .svn files/directories under current directory
find . -name .svn |xargs rm -rf
Delete all .svn subdirectories under current directory
rm -rf `find . -type d -name ".svn"`
Delete all 1US* (case insensitive) files under current directory
find . -iname "1US*" -exec rm {} \;
Delete all __temp__* directories under maximum 1 level down the current directory tree
find . -maxdepth 1 -type d -name '__temp__*' -print0 | xargs -0 rm -rf
delete all the backup files in current directory
find . -name "*.bak" -delete
Delete all broken symbolic links under '/usr/ports/packages' directory tree
find -L /usr/ports/packages -type l -exec rm -- {} +
Delete all but the most recent 5 files
ls -tr | head -n -5 | xargs rm
delete all the core files in the folder /prog which are bigger than 1KB
find /prog -type f -size +1000 -print -name core -exec rm {} \;
delete all the directories empty directories in the current folder
find . -type d -empty -delete