nl
stringlengths
13
387
bash
stringlengths
1
532
Do a dry run of renaming file extension '.andnav' to '.tile' for all files/directories under current directory tree
find . -name "*.andnav" | rename -vn "s/\.andnav$/.tile/"
Add "execute" to the permissions of all directories in the home directory tree
find ~ -type d -exec chmod +x {} \;
Add "new." to the beginning of the name of "original.filename", renaming it to "new.original.filename".
rename 's/(.*)$/new.$1/' original.filename
Add "new." to the beginning of the name of "original.filename", renaming it to "new.original.filename".
rename 's/^/new./' original.filename
Add "prefix" to every non-blank line in "file.txt"
nl -s prefix file.txt | cut -c7-
Add '.avi' extension to all files/directories with '.mkv' extension under '/volume1/uploads' directory tree
find /volume1/uploads -name "*.mkv" -exec mv \{\} \{\}.avi \;
Add a cron job to existing list, without removing existing ones, ro tun "scripty.sh" at 2:01 am, 3rd day of april (4th month), if that day happens to be a friday (5th day of the week starting with sunday=0).
cat <(crontab -l) <(echo "1 2 3 4 5 scripty.sh") | crontab -
Add a date time stamp to every line of output in "ping google.com"
ping google.com | xargs -L 1 -I '{}' date '+%c: {}'
Add a line number to every line in "infile"
nl -ba infile
Add a line number to every line in "long-file"
nl -ba long-file \
Add a number prefix followed by ')' to each line in "$string"
echo "$string" | nl -ba -s') '
Add content of "filename" to the existing cron jobs of user "user", without removing the previously existing cron jobs.
crontab -l -u user | cat - filename | crontab -u user -
Add cron lists from "file1" and "file2" to list of cron jobs, giving errors for any lines that cannot be parsed by crontab.
cat file1 file2 | crontab
Add the execute and read permission for all and the write permission for the user to the dir_data directory and all of its sub-directories.
find ~/dir_data -type d -exec chmod a+xr,u+w {} \;
Add execute permission to "ComputeDate", "col", and "printdirections" for all users
chmod a+x ComputeDate col printdirections
Add executable permission to "java_ee_sdk-6u2-jdk-linux-x64.sh"
sudo chmod +x java_ee_sdk-6u2-jdk-linux-x64.sh
Add execute permission to all files ending in ".sh"
chmod +x *.sh
Add group write permission to all files and directories in the current directory including hidden files and excluding ".."
chmod g+w $(ls -1a | grep -v '^..$')
Add group write permission to all files and directories in the current directory including hidden files and excluding ".."
chmod g+w .[^.]* ..?*
Add group write permission to all files in the current directory
find . -maxdepth 0 -type f -exec chmod g+w {} ';'
Add group write permission to all files matching "*" or "...*"
chmod g+w * ...*
Add line numbers to each non-blank line in "file" starting with number 1000001
nl -v1000001 file
Add prefix like number and "^M${LOGFILE}> " to every non-blank line received on standard input
nl -s"^M${LOGFILE}> "
Add read and execute permission to command "node"
sudo chmod +rx $(which node)
Add read and execute permission to every directory under the current directory
find . -type d -exec chmod +rx {} \;
Add read permission for 'other' for all files/directories named 'rc.conf' under current directory tree
find . -name "rc.conf" -exec chmod o+r '{}' \;
add read permission to others for the files in the current folder having the name "rc.conf" in their name.
find . -name "*rc.conf" -exec chmod o+r '{}' \;
Add variable TESTVAR with value "bbb" to a temporary environment, and search for TESTVAR in all variables and their values in the resulting environment.
TESTVAR=bbb env | fgrep TESTVAR
Adjust the timestamp of 'filename' by subtracting 2 hours from it.
touch -d "$(date -r filename) - 2 hours" filename
Adjust the timestamp of file $filename by subtracting 2 hours from it
touch -d "$(date -r "$filename") - 2 hours" "$filename"
all .jpg or .png images modified in the past week
find . -mtime -7 \( '*.jpg' -o -name '*.png' \)
all the files that end with .mp3 and end with .jpg
find . -name '*.mp3' -name '*.jpg' -print
Allow all users to execute "myscript.sh"
chmod a+x myscript.sh
Allow all users to execute '$pathToShell"myShell.sh"'
chmod a+x $pathToShell"myShell.sh"
Allow anyone to run command "Xvfb" as the owner of "Xvfb"
sudo chmod u+s `which Xvfb`
Answer "y" to all prompts of "rm -rf foo"
yes | rm -ri foo
Answer "y" to any prompts in the interactive recursive removal of "dir1", "dir2", and "dir3"
yes y | rm -ir dir1 dir2 dir3
Append ".txt" to all filenames in the current directory tree
find -type f | xargs -I {} mv {} {}.txt
Append *.java files from the current directory tree to tar archive `myfile.tar'
find . -type f -name "*.java" | xargs tar rvf myfile.tar
Append all *.mp3 files modified within the last 180 days to tar archive `music.tar'
find . -name -type f '*.mp3' -mtime -180 -print0 | xargs -0 tar rvf music.tar
Append all PNG and JPG files to tar archive 'images.tar'
find . \( -iname "*.png" -o -iname "*.jpg" \) -print -exec tar -rf images.tar {} \;
Append all regular files modified in the last 24 hours to the "$archive.tar" tar archive
find . -mtime -1 -type f -exec tar rvf "$archive.tar" '{}' \;
Append all regular files modified in the last 24 hours to the "$archive.tar" tar archive
find . -mtime -1 -type f -print0 | xargs -0 tar rvf "$archive.tar"
Append the contents of ".cwdhist" file to the current in-memory history list
history -r .cwdhist
Append the contents of "file.txt" to the current in-memory history list
history -r file.txt
Append the current date in '%Y%m%d_%H%M' format with the basename of $0 and save it to variable 'LOGNAME'
LOGNAME="`basename "$0"`_`date "+%Y%m%d_%H%M"`"
Append the current date in '%d%m%Y-%H-%M' format, '_' and the current username, then save it in 'name' variable
name="$(date +'%d%m%Y-%H-%M')_$(whoami)"
Append the date and command ran to "/tmp/trace" after every command
PROMPT_COMMAND='echo "$(date +"%Y/%m/%d (%H:%M)") $(history 1 |cut -c 7-)" >> /tmp/trace'
Append history lines from this session to the history list
history -a
Archive "./dir" to "user@host:/path" via ssh on port 2222 and display progress
rsync -rvz -e 'ssh -p 2222' --progress ./dir user@host:/path
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/
Archive "/home/abc/*" to "/mnt/windowsabc" with human readable output
rsync -avh /home/abc/* /mnt/windowsabc
Archive "/home/path" to "path" on host "server" showing progress and statistics and remove files in the destination not found in the source
rsync -a --stats --progress --delete /home/path server:path
Archive "/home/user1" to "wobgalaxy02:/home/user1" excluding hidden files
rsync -av /home/user1 wobgalaxy02:/home/user1
Archive "/local/path/some_file" to "/some/path" on host "server.com" authenticating as user "usr", compress data during transmission, show progress details.
rsync -avz --progress local/path/some_file [email protected]:"/some/path/"
Archive "/media/10001/music/" on host "server" to local directory "/media/incoming/music/" and skip files that are newer in the destination, delete any files in the destination not in the source, and compress data during transmission
rsync -avzru --delete-excluded server:/media/10001/music/ /media/Incoming/music/
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 .
Archive "/path/to/application.ini" on host "source_host" to current directory.
rsync -avv source_host:path/to/application.ini ./application.ini
Archive "/path/to/copy" to "/path/to/local/storage" on host "host.remoted.from" as user "user" updating files with different checksums, showing human readable progress and statistics, and compressing data during transmission
rsync -chavzP --stats /path/to/copy [email protected]:/path/to/local/storage
Archive "/path/to/files" to "/path" on host "user@targethost" with elevated permission on the remote host
rsync -av --rsync-path="sudo rsync" /path/to/files user@targethost:/path
Archive "/path/to/files" to "user@targethost:/path"
rsync -av /path/to/files user@targethost:/path
Archive "/path/to/files/source" to "user@remoteip:/path/to/files/destination" via ssh on port 2121
rsync -azP -e "ssh -p 2121" /path/to/files/source user@remoteip:/path/to/files/destination
Archive "/path/to/sfolder" to "[email protected]:/path/to/remote/dfolder" preserving hard links and compressing the data during transmission
rsync -aHvz /path/to/sfolder [email protected]:/path/to/remote/dfolder
Archive "/path/to/sfolder/" to "[email protected]:/path/to/remote/dfolder" preserving hard links and compressing the data during transmission
rsync -aHvz /path/to/sfolder/ [email protected]:/path/to/remote/dfolder
Archive "/source" and all files under "folder/" to "/dstfolder/" on host "remoteserver" as user "user" without copying files that already exist
rsync -avz --ignore-existing /source folder/* user@remoteserver:/dstfolder/
Archive "/source/backup" to "/destination" with compression during transfer
rsync -ravz /source/backup /destination
Archive "/top/a/b/c/d" to host "remote" using relative path names
rsync -a --relative /top/a/b/c/d remote:/
Archive "/usr/local/" to "/BackUp/usr/local/" on host "XXX.XXX.XXX.XXX" via ssh and show progress
rsync --progress -avhe ssh /usr/local/ XXX.XXX.XXX.XXX:/BackUp/usr/local/
Archive "/var/www/test/" to "/var/www/test" on host "231.210.24.48" as user "ubuntu" via ssh using identity file "/home/test/pkey_new.pem"
rsync -rave "ssh -i /home/test/pkey_new.pem" /var/www/test/ [email protected]:/var/www/test
Archive "_vim/" to "~/.vim" suppressing non-error messages and compressing data during transmission
rsync -aqz _vim/ ~/.vim
Archive "blanktest/" to "test/" deleting any files in the destination not found in the source
rsync -a --delete blanktest/ test/
Archive "directory" preserving hard links from host "remote" to the current local directory and keep partial files, handle sparse files efficiently, and itemize changes made
rsync -aPSHiv remote:directory .
Archive "fileToCopy" to "/some/nonExisting/dirToCopyTO" on host "ssh.myhost.net" via ssh
rsync -ave ssh fileToCopy ssh.myhost.net:/some/nonExisting/dirToCopyTO
Archive "path/subfolder" to "path", skipping files that are newer at the destination.
rsync -vuar --delete-after path/subfolder/ path/
Archive "path/to/working/copy" to "path/to/export" excluding files or directories named ".svn"
rsync -a --exclude .svn path/to/working/copy path/to/export
Archive "somedir/./foo/bar/baz.c" to "remote:/tmp/" preserving the relative path of "foo/bar/baz.c"
rsync -avR somedir/./foo/bar/baz.c remote:/tmp/
Archive "source" to "destination" via ssh on port "PORT_NUMBER"
rsync -azP -e "ssh -p PORT_NUMBER" source destination
Archive "src" to "dst" updating files existing in "dst"
rsync -a -v src dst
Archive "src" to "dst" without overwriting existing files in "dst"
rsync -a -v --ignore-existing src dst
Archive "src-dir" to "dest-dir" on "remote-user@remote-host" and delete any files in "dest-dir" not found in "src-dir"
rsync -av --delete src-dir remote-user@remote-host:dest-dir
Archive all ".txt" files in the current directory to "/path/to/dest" keeping partially transferred files
rsync -aP --include=*/ --include=*.txt --exclude=* . /path/to/dest
Archive all *.xml files under current directory tree to xml.tar excluding the files that match '/workspace/' in their paths
find . -name \*.xml | grep -v /workspace/ | tr '\n' '\0' | xargs -0 tar -cf xml.tar
Archive all *html files using tar.
find . -type f -name "*html" | xargs tar cvf htmlfiles.tar -
Archive all directories in /path/to/directory/* (only command line arguments, no sub-directories) to files with .tar.gz extension
find /path/to/directory/* -maxdepth 0 -type d -printf "%P\n" -exec sudo tar -zcpvf {}.tar.gz {} \;
Archive all directories in /path/to/directory/* (only command line arguments, no sub-directories) to files with .tar.gz extension transforming the full paths to relative paths
find /path/* -maxdepth 0 -type d -exec sudo tar -zcpvf {}.tar.gz {} \;
archive all files in a current directory modified in the last 30 days
tar czvf mytarfile.tgz `find . -mtime -30`
Archive all filepattern-*2009* files/directories under data/ into 2009.tar
find data/ -name 'filepattern-*2009*' -exec tar uf 2009.tar '{}' +
Archive all filepattern-*2009* files/directories under data/ into 2009.tar
find data/ -name filepattern-*2009* -exec tar uf 2009.tar {} ;
Archive all filepattern-*2009* files/directories under data/ into 2009.tar
find data/ -name filepattern-*2009* -print0 | xargs -0 tar uf 2009.tar
archive all the normal/regular files in the current directory which have been modified in the last 24 hours.
find . -mtime -1 -type f -exec tar rvf "$archive.tar" '{}' \;
Archive any files changed in the last day from "remote_host" to "local_dir"
rsync -av remote_host:'$(find logs -type f -ctime -1)' local_dir
Archive current directory to "/some/path" on localhost, using ssh to authentify as user "me", only update files that are newer in the source directory.
rsync -auve "ssh -p 2222" . me@localhost:/some/path
Archive directory "." to "server2::sharename/B"
rsync -av . server2::sharename/B
Archive directory "/mnt/data" to "/media/WD_Disk_1/current_working_data/", deleting any extraneous files in destination, compress data during copy.
rsync -az --delete /mnt/data/ /media/WD_Disk_1/current_working_data/;
Archive directory "symdir" to "symdir_output" preserving symbolic links.
rsync symdir/ symdir_output/ -a --copy-links -v
Archive the entire file system into tarfile.tar.bz2
find / -print0 | xargs -0 tar cjf tarfile.tar.bz2
Archive file 'file' with bzip2 tool, store compressed data to a file 'logfile' and also print to screen
bzip2 -c file | tee -a logfile
Archive files in "/mnt/source-tmp" to "/media/destination"
rsync -a /mnt/source-tmp /media/destination/
Archive files (not directories) in "sorce_dir" to "target_dir"
rsync -a --filter="-! */" sorce_dir/ target_dir/
Archive the list of 1st level subdirectories in /fss/fin to /fss/fi/outfile.tar.gz
tar -czf /fss/fi/outfile.tar.gz `find /fss/fin -d 1 -type d -name "*" -print`
README.md exists but content is empty.
Downloads last month
209

Models trained or fine-tuned on jiacheng-ye/nl2bash