nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Search directories /path/to/directory/folder{1..50} for .txt files, outputting only the names of the matched files stripped of the .txt suffix
|
find /path/to/directory/folder{1..50} -name '*.txt' -exec basename {} .txt \; 2>/dev/null
|
Display the last 3 characters of variable foo.
|
echo $foo | rev | cut -c1-3 | rev
|
Lists all files and folders with its content in a current folder, excluding names ending with 'foo'.
|
ls !
|
Print the file sizes along with their paths for all *.txt files/directories under current directory tree
|
find . -name "*.txt" -print0 |xargs -0 du -ch
|
Save IP addresses of the host name in variable "ip"
|
ip=$(hostname -I | awk '{print $1}')
|
Print the grand total disk usage of all files listed in "files.txt"
|
cat files.txt | xargs du -c | tail -1
|
Search for regular expression 'expr' in all .c and .h files from the current directory tree
|
find -name '*.[ch]' | xargs grep -E 'expr'
|
find all the jpg files in the directory /ftp/dir which are bigger than 500KB
|
find /ftp/dir/ -size +500k -iname "*.jpg"
|
display all directories in vim folder do not search in sub directories
|
find .vim/ -maxdepth 1 -type d
|
find all the non compressed files in the current directory and compress them.
|
find . \! -name "*.Z" -exec compress -f {} \;
|
Find all directories under current directory and set read & execute permission for group and other for these files
|
find . -type d -print0 | xargs -0 chmod go+rx
|
Recursively change the owner and group of all files in the current directory to "apache"
|
ls | xargs chown -R apache:apache
|
Find all *.php files and *.js files/directories under /home/jul/here excluding $EXCLUDE/* paths
|
find /home/jul/here -type f -iname "*.php" ! -path "$EXCLUDE/*" -o -iname "*.js" ! -path "$EXCLUDE/*"
|
Search the directories that match pattern '/path/to/directory/folder{?,[1-4]?,50}' for .txt files
|
find /path/to/directory/folder{?,[1-4]?,50} -name '*.txt'
|
Print the git log in a tabular form
|
git log --pretty=format:'%h|%an|%s' -10 | column -t -s '|'
|
Find all hidden files starting from the directory given as variable $FOLDER
|
find $FOLDER -name ".*"
|
Delete all files under user's home directory tree that were accessed more than 365 days after their status was changed
|
find ~ -used +365 -ok rm '{}' ';'
|
Find all regular files in <path> and execute process with all of them as arguments
|
find <path> -type f -exec sh -c 'for f; do echo process $f; done' sh {} +
|
create directory /path/to/destination
|
mkdir /path/to/destination
|
List files that have been renamed in Git repository.
|
find -name .git -prune -o -exec git log --pretty=tformat:'' --numstat --follow --find-copies-harder --reverse {} ';' | cut -f3- | grep '.* => .*'
|
find all the regular/normal files in the current folder
|
find -type f
|
Find all regular files whose names contain "@" in directory tree ~/$folder
|
find ~/$folder -name "*@*" -type f -print0
|
Find all files/directories named 'document' in the entire filesystem
|
find / -name document -print
|
Print full path of command "c++"
|
which c++
|
Search for 'class Pool' in all *.java (case insensitive) files under current directory
|
find -iname '*.java'|xargs grep 'class Pool'
|
search for all the files in the current directory which have size greater than 10KB and less than 32KB.
|
find . -size +10000c -size -32000c -print
|
find all the files in the entire file system which have been modified in the last 5 days
|
find / -mtime -5 -print
|
Find .rmv files in the ./root directory recursively and copy them to directory /copy/to/here
|
find root -name '*.rmv' -type f -exec cp --parents "{}" /copy/to/here \;
|
Find all flies under current directory excluding *.png files and print the file paths that match the case insensitive regex 'foo=' in their contents
|
find . -not -name '*.png' -o -type f -print | xargs grep -icl "foo="
|
Print the names of all files and directories in the current directory tree
|
find . -print
|
Find files/directories under current directory that matches the regex /projects/insanewebproject[^/]*$ in their paths
|
find . -exec sh -c 'echo {} | grep -qi /projects/insanewebproject[^/]*$' \; -print
|
find all files in current folder and display the total lines in them
|
find . | xargs wc -l
|
Remove all *.mp3 files in tmp directory but not in it's subdirectories
|
find tmp -maxdepth 1 -name *.mp3 -print0 | xargs -0 rm
|
Find all *.jpg files under maximum 2 levels down the temp/medium/* paths and run `mogrify -resize 428x270"^" -quality 80 -compress JPEG -monitor -strip` with the file paths as arguments
|
find temp/medium/* -maxdepth 2 -iname "*.jpg" -print0 | xargs -0 mogrify -resize 428x270"^" -quality 80 -compress JPEG -monitor -strip
|
Search the home directory for filenames starting with "xx" except for "xxx" files
|
find ~ -name 'xx*' -and -not -name 'xxx'
|
Shows status of a shell option 'dotglob'.
|
shopt dotglob
|
Displays process tree of a process with id 'PID', showing parent process and processes id.
|
pstree -p -s PID
|
Change the owner to "user" and group to "group" of files "file ..."
|
chown user:group file ...
|
Replace all occurrence of "subdomainA.example.com" with "subdomainB.example.com" in all files under /home/www and below
|
find /home/www -type f -print0 | xargs -0 sed -i 's/subdomainA.example.com/subdomainB.example.com/g'
|
Gets IP address of 'en1' network interface.
|
my_ip=$
|
Change the owner of all files in the directory tree "dir_to_start" excluding file "file_to_exclude" to "owner"
|
find dir_to_start -not -name "file_to_exclude" -print0 | xargs -0 chown owner
|
Show directory sizes in KB and sort to give the largest at the end
|
du -sk $ | sort -n -k 1
|
Print the full path of command "rails"
|
which rails
|
Page through the output of running the specified PHP file.
|
less -f <
|
search for all the files in the current folder and sort them in the order of their depth and display the file names
|
find -type d -printf '%d\t%P\n' | sort -r -nk1 | cut -f2-
|
Lists all directories in '/home/alice/Documents/'.
|
ls -d /home/alice/Documents/*/
|
Recursively bind mount "/something" on "/new_something"
|
mount --rbind /something /new_something
|
Search for empty files
|
find . -size 0k
|
Print NS record for domain 'domain.' from 8.8.8.8 nameserver
|
dig @8.8.8.8 domain. ns
|
Display the contents of variable "a" converted to lowercase.
|
echo "$a" | awk '{print tolower($0)}'
|
display a list of all the files in the file system which do not belong to any user and search only in jfs and jfs2 file systems
|
find / -nouser \ -ls
|
Change permissions to 644 recursively for PHP files.
|
find . -type f -name '*.php' -exec chmod 644 {} \;
|
List all your files including everything in sub-directories
|
find ~
|
Installs 'php-mssql' package with enabling repository 'remi'.
|
yum --enablerepo=remi php-mssql
|
On host "server_b", connect as ssh user "user" and copy "/my_folder/my_file.xml" to directory "/my_new_folder/", with all transfer data relayed through local host.
|
scp -3 user@server_b:/my_folder/my_file.xml user@server_b:/my_new_folder/
|
Search the files from directory tree "dirname" for string "foo"
|
find dirname -print0 | xargs -0 grep foo
|
Rename "file0001.txt" to "1.txt"
|
mv file0001.txt 1.txt
|
split content of the file file.txt started from second line into pieces per 4 lines named as split_NNN
|
tail -n +2 file.txt | split -l 4 - split_
|
Searches the manual page names and descriptions
|
apropos
|
Sort the contents of file "ips.txt", eliminate duplicate entries, and prefix each entry with number of occurrences.
|
sort ips.txt | uniq -c
|
Find all files under current directory and set read-write permission for owner, read permission for group and no permission for other for those files
|
find . -type f -exec chmod u=rw,g=r,o= '{}' \;
|
delete all text files from current folder
|
find . -type f ! -iname "*.txt" -delete
|
Print the base name of the current working directory
|
echo "$(basename $)"
|
Search the current directory for all regular files executable by 'user', 'group', and 'others'
|
find . -maxdepth 1 -type f -perm -ugo=x
|
Find all php files under current directory
|
find . -type f -name "*.php"
|
Mount "/tmp/loop.img" on "/mnt/image" as a loop back device
|
mount /tmp/loop.img /mnt/image -o loop
|
Find all *.txt files/directories under current directory and execute the python script hello.py with all their paths as arguments
|
find . -name "*.txt" -print0 | xargs -0 python hello.py
|
find all the ".c" files in the folder "/home/you" which have been accessed in the last 30*24 hours
|
find /home/you -iname "*.c" -atime -30 -type -f
|
change the word "GHBAG" to "stream-agg" in all the file names in current folder which have the word "-GHBAG-" in their name
|
find . -name '*-GHBAG-*' -exec rename 's/GHBAG/stream-agg/' {} +
|
Lists all subdirectories in the current directory
|
ls -d -- */ ### more reliable GNU ls
|
display all the directories in the folder /path/to/dest except tmp directory
|
find /path/to/dest -type d \( ! -name tmp \) -print
|
Remove spaces recursively from all subdirectories under current directory
|
find /path/to/dir -type d | tac | while read LINE; do target=$/$; echo mv "$LINE" "$target"; done
|
Count the number of directories in the current directory and below
|
find . -type f -exec basename {} \; | wc -l
|
Find files that were modified 7 days ago and archive them
|
find . -type f -mtime 7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
|
Print unique lines in "set1" and "set2" when compared to each other and remove any tabs
|
comm -3 < < | sed 's/\t//g'
|
Recursively copies /mnt/usr/lib to the '/usr/' directory, creating symbolic links on each file instead of real copying them.
|
cp -rs /mnt/usr/lib /usr/
|
Run rsync with options specified by variable OPTS, copying directory(ies) specified by variable FIND, and to destination specified by variable BACKUPDIR.
|
rsync $OPTS $FIND $BACKUPDIR
|
change the group of all regular/normal files in the current directory
|
find . -type f -exec chgrp usergroup {} \;
|
Show files in maximum 1 level down the current directory that were modified less than 1 day ago from today
|
less `find -maxdepth 1 -type f -daystart -mtime -1`
|
find all the files in the current folder which have been modified in the last one day
|
find . -daystart -mtime -1 -ls
|
Recursively copies 'SRCFOLDER' to the 'DESTFOLDER/'
|
cp -R SRCFOLDER DESTFOLDER/
|
Remove the "^M" characters from all *.ext files under /home directory and save the results to new files with _new appended in their names
|
find /home -type f -name "*.ext" -print0 | while read -r -d "$" -r path; do dos2unix $path $path"_new"; done
|
Find all regular files in the current directory tree that are not readable by anyone
|
find . -type f ! -perm -444
|
Print the contents of "file" with " | " appended to each line
|
echo `sed -e 's/$/\ |\ /g' file`
|
Find all files/directories under current directory tree that start with 'test' in their names without descending into directories with the same name pattern
|
find . -name 'test*' -prune
|
Delete all 'restore.php' files in /var/www and 3 levels below
|
find /var/www -maxdepth 4 -name 'restore.php' -exec rm -r {} \;
|
search for the directory starting with "ora10" in the entire file system
|
find / -type d -name "ora10*"
|
Move all files/directories under current directory to ~/play
|
find . -exec mv '{}' ~/play/ \;
|
Find all files under /path/to/input/ that match the case insensitive string literal '[email protected]' in their contents
|
find /path/to/input/ -type f -exec grep -qiF [email protected] \{\} \; -print
|
Login to "host" using identity file "id_rsa"
|
ssh -i id_rsa host
|
display all the directories in the current folder which start with processor followed by digit and ends with .1 or .2
|
find . -type d -regextype posix-egrep -regex '\./processor[0-9]*/10\.(1|2)'
|
Count lines that are neither blanks nor comments in a file 'foo.pl'
|
cat foo.pl | sed '/^\s*#/d;/^\s*$/d' | wc -l
|
Find all files under current directory and change their permission to 400
|
find . -type f -exec chmod 400 {} \;
|
Search only for directories
|
find -type d
|
Search the /myfiles directory tree for files last accessed more than 30 days ago
|
find /myfiles -atime +30
|
Remove the last line from "$file" without reading the whole file or rewriting anything
|
tail -n 1 "$file" | wc -c | xargs -I {} truncate "$file" -s -{}
|
find the file "filename.txt" in the usr folder
|
find /usr -name filename.txt -print
|
Find all directories under 'test' directory tree whose paths match the regex '.*/course[0-9]\.[0-9]\.[0-9]\.[0-9]$'
|
find test -type d -regex '.*/course[0-9]\.[0-9]\.[0-9]\.[0-9]$'
|
Find all *.mov files under current directory and run an ffmpeg command with the literal '%p' and '%f' as the path and name respectively for each file
|
find . -iname "*.mov" -exec ffmpeg -i "%p" -f flv "%f" \;
|
Find all directories named postgis-2.0.0 under / directory
|
sudo find / -type d -name "postgis-2.0.0"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.