nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Silently read a line into variable "passwd" with prompt "Enter your password: "
|
read -s -p "Enter your password: " passwd
|
Find all of jzb's files
|
find -user jzb
|
Recursively finds all files containing text 'OPEN' and prints folder where they are placed.
|
grep -r OPEN * | awk '{split($1, path, ":"); print path[1]}' | xargs -I{} dirname {}
|
Find all *.rb files under current directory and count their line numbers
|
find . -name "*.rb" -type f -exec wc -l \{\} \;
|
Find all files/directories named modules under current directory and list them twice
|
find . -name modules \! -exec sh -c 'find -name modules' \;
|
prints last part of a logfile since timestamp 423
|
tac file.log | awk '{ if print; else exit; }' | tac
|
Remove files under current directory with inode number $inum
|
find . -inum $inum -exec rm {} \;
|
Find files under [directory] that match 'pattern_to_INCLUDE' in their names without descending into directories that match 'pattern_to_exclude' and 'another_pattern_to_exclude', then search for 'pattern' in those files
|
find [directory] -name "pattern_to_exclude" -prune -o -name "another_pattern_to_exclude" -prune -o -name "pattern_to_INCLUDE" -print0 | xargs -0 -I FILENAME grep -IR "pattern" FILENAME
|
find all regex ".*/[a-f0-9\-]\{36\}\.jpg" files
|
find . -regextype sed -regex ".*/[a-f0-9\-]\{36\}\.jpg"
|
change the permissions of all the regular/normal files to 644 in the folder /home/nobody/public_html
|
find /home/nobody/public_html -type f -exec chmod 644 {} \;
|
display the count of total number of empty files in the current folder
|
find . -type f -empty | wc -l
|
Set read, write and execute permission for all for the files/directories in foldername directory tree
|
sudo find foldername -exec chmod a+rwx {} ";"
|
Counts lines in file 'file1' and shows progress bar while doing.
|
pv file1 | wc -l
|
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`;
|
Compare text "hello" and "goodbye" line by line
|
diff <(echo hello) <(echo goodbye)
|
Print numbered list of all third-level files under the current directory
|
ls -d -1 $PWD/**/*/* | cat -n
|
Remove leading and trailing spaces or tabs from " wordA wordB wordC "
|
echo " wordA wordB wordC " | sed -e 's/^[ \t]*//' | sed -e 's/[ \t]*$//'
|
Find all files under current directory and set read-write permission for owner and group and no permission for other for those directories
|
find . -type f -exec chmod ug=rw,o= {} \;
|
Remove files in the current directory tree modified more than 31 days ago recursively
|
find . -type f -mtime +31 -print0 | xargs -0 -r rm -f
|
search for the file job.hostory in the folder "/data/Spoolln"
|
find /data/SpoolIn -name job.history
|
Print lines in the sorted contents of "file1" that are not in the sorted contents of "file2"
|
comm -23 < <
|
download file "https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh" and execute it
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
|
Synchronize "xxx-files" to "different-stuff/xxx-files" recursively preserving metadata with a bandwidth limit of 2000 KiB/s
|
rsync -pogtEtvr --progress --bwlimit=2000 xxx-files different-stuff
|
Delete all files under $INTRANETDESTINATION/weekly directory tree that were modified more than 32 days ago
|
find $INTRANETDESTINATION/weekly -mtime +32 -exec rm {} \;
|
Print file size with the file name
|
find . -name '*.ear' -exec du -h {} \;
|
find all the files in the current directory which are bigger than 1000MB
|
find . -size +1000M
|
List every symbolic link in every home directory's subdirectory owned by group `staff'
|
find `pwd` -group staff -exec find {} -type l -print ;
|
View gzip's help documentation
|
gzip --help | less
|
Find all directories that start with stat
|
find . -type d –iname stat*
|
find all the files in the current folder that end with the word bar
|
find -name *bar
|
Search for 'It took' in all $srch1* files under current directory
|
find . -iname "$srch1*" -exec grep "It took" {} \; -print
|
Execute /usr/bin/find with $* arguments where current directory is the first argument
|
/usr/bin/find ./ $*
|
Find all files/directories under current directory without descending into './bookshop/mediaimg', '*/CVS*', './files', './images/cms', './internal', './limesurvey171plus_build5638' and './gallery2' paths, then run cvs command with 'status' and each path as arguments and redirect the output to output.txt fle
|
for i in `find . -not \ -path './bookshop/mediaimg' -prune -o -path '*/CVS*' -prune -o -path './files' -prune -o -path './images/cms' -prune -o -path './internal' -prune -o -path './limesurvey171plus_build5638' -prune -o -path './gallery2' -prune -o -print `; do cvs status "$i" |grep Status ; done &>~/output.txt
|
List all the file links
|
find . -type l
|
Continuously send "y" as input to "cat" which outputs to "more"
|
yes | cat | more
|
Page through the output of 'some_command' positioning the view at the first occurrence of regular expression 'regex'.
|
some_command | less -p regex
|
Find all the files/directories in '/path/to/files' directory tree which have not been modified in the last 2 hours
|
find "/path/to/files" -mmin +120
|
Recursively finds strings with the whole word 'word-1' or 'word-2' in any file under 'directory-path', following symlinks, and prints found strings.
|
egrep -w -R "word-1|word-2” directory-path
|
Duplicate directory tree under /mnt/usr/lib to /usr but creating symlinks to files instead of copying them.
|
cp -rs /mnt/usr/lib /usr/
|
Find all files in /home/user/ that were created or changed 10 minutes ago
|
find /home/user/ -cmin 10 -print
|
Creates temporary folder in TMPDIR or in '/tmp/', and stores path to created folder in 'tmpdir' variable.
|
tmpdir=$
|
Print all user names and terminals of users who are logged in
|
who | cut -d " " -f1,2
|
Recursively remove all "*.txt" files and answer "n" to any prompt
|
yes n | rm -r *.txt
|
Cut all remote paths from HTTP URLs received from standard input (one per line) keeping only the protocol identifier, host name, and trailing slash, of the form http://example.com/
|
sed -n 's;\(http://[^/]*/\).*;\1;p'
|
Find all *.plist files/directories under current directory
|
find . -name \*.plist
|
Search the current directory recursively for regular files last modified more than 2 days ago
|
find . type -f -mtime +2
|
Find all *.txt files/directories under current directory and execute process for each of them
|
find . -name \*.txt -print0 | xargs -0 -I{} process {} argument
|
Print the list of the current directory's subdirectories
|
find . -maxdepth 1 -mindepth 1 -type d -printf '%f\n'
|
Format "$line" as a table
|
echo "$line" | column -t
|
change owner of the files into directory dir_to_start except directory dir_to_exclude to user owner
|
find dir_to_start -name dir_to_exclude -prune -o -print0 | xargs -0 chown owner
|
print the names of all of the unstripped binaries in the /usr/local directory tree. Builtin tests avoid running file on files that are not regular files or are not executable
|
find /usr/local -type f -perm /a=x | xargs file | grep 'not stripped' | cut -d: -f1
|
Use 'less' to nicely display control characters from the outupt of 'grep'.
|
grep -b -o $'\x0c' filename | less
|
Search for files/directories with the case insensitive pattern anaconda.* in var/log directory and create an archive of the last file found
|
find var/log/ -iname anaconda.* -exec tar -cvf file.tar {} \;
|
Find all the files in file system which are modified more than 50 days back and less than 100 days
|
find / -mtime +50 –mtime -100
|
Search for all files that end in ".conf"
|
find / -type f -name "*.conf"
|
Split "foo.txt" into files with 1 line each and use a suffix length of 5
|
split --suffix-length=5 --lines=1 foo.txt
|
Find files readable only by the group
|
find . -perm g=r -type f -exec ls -l {} \;
|
display all the files in current folder which start with "file2015-0"
|
find . -name "file2015-0*"
|
Search the current user's home directory and its sub-directories for any file that was modified less than 2 days ago or was modified after filename was last modified.
|
find ~/ -mtime -2 -o -newer filename
|
Sort lines in "FILE" to standard output preserving only unique lines
|
sort -u FILE
|
Print 3 space separated '%'
|
echo $
|
Make directory "foo" and do not cause an error if it exists
|
mkdir -p foo
|
Find all .java files starting from the current folder
|
find * -name "*.java"
|
display all the configuration files in the current folder which are in the current tree structure
|
find . -path '*/*config'
|
Remove empty directories from the current directory tree
|
find . -depth -empty -type d -delete
|
Find all files/directories startring with 'onlyme' in their names under current directory without going into sub-directories
|
find . -maxdepth 1 -name 'onlyme*'
|
Find & replace broken symbolic links
|
find -L . -type l -delete -exec ln -s new_target {} \;
|
Run "./configure" with a new environment variable CC set to the full path of the command 'cc'
|
CC=$(which cc) ./configure
|
Find files/directories under '/dir' directory tree that are newer than 'yesterday.ref' file and older than 'today.ref' file by modification time
|
find /dir -newer yesterday.ref -a \! -newer today.ref -print
|
Find all files/directories with '.c' or '.h' extension under current directory tree and search for the regex provided by first positional argument and show the output by paging through one screenful at a time
|
find . -name '*.[ch]' | xargs grep $1 | less
|
Executes command 'cd ~/server' in an opened tmux session 'cf'.
|
tmux send-keys -t cf 'cd ~/server' C-m
|
search for all the files in the folder /data/images which are modified after /tmp/foo
|
find /data/images -newer /tmp/foo
|
Kills all child process and process itself having id 24901.
|
kill `pstree -p 24901 | sed 's/(/\n(/g' | grep '(' | sed 's/(\).*/\1/' | tr "\n" " "`
|
View manual page of find utility
|
man find
|
See what files are executable by the file's owner and group
|
find -type f -perm -110
|
find all the ".jpg" files in current folder and display their count
|
find ./ -name '*.jpg' -type f | wc -l
|
Find all .sh files in or below the current directory and move them to folder ~/back.scripts
|
find . -name "*.sh" -print0 | xargs -0 -I file mv file ~/back.scripts
|
Resolve any symlinks in working directory, and go to resulting pathname.
|
cd "`pwd -P`"
|
Search the file system for regular files whose names are shorter than 25 characters
|
find / -type f | egrep '.*/.{1,24}$'
|
Change directory to the directory containing the executable file of command "oracle"
|
cd $(which oracle | xargs dirname)
|
download contents from "https://raw.github.com/creationix/nvm/master/install.sh" and execute
|
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
|
Set the variable "me" to the name of the running script, or shell, login shells have a hyphen appended to the beginning of the name, such as "-bash".
|
me=`basename -- "$0"`
|
Search for the regex \s1$ in all files under current directory
|
find . -type f -exec perl -wnl -e '/\s1$/ and print' {} +
|
Print name of the block device containing the file system containing $path.
|
df -P "$path" | awk 'BEGIN {FS="[ ]*[0-9]+%?[ ]+"}; NR==2 {print $1}'
|
run command 'ls -hal /root/ > /root/test.out' as user root
|
sudo su -c 'ls -hal /root/ > /root/test.out'
|
Find all files in ~/clang+llvm-3.3/bin/ and print 'basename /file/path' for each file
|
find ~/clang+llvm-3.3/bin/ -type f -exec echo basename {} \;
|
display list of all the hidden files in the home folder
|
find $HOME -name ".*" -ls
|
Counts lines of /dir/file.txt file.
|
wc -l /dir/file.txt
|
Display unique names of logged in users
|
finger | sed 's/\t/ /' | sed 's/pts\/[0-9]* *[0-9]*//' | awk '{print $2"\t\t"$3" "$4" "$5}' | sort | uniq
|
Search the /Applications directory tree for *.app directories
|
find /Applications -type d -name "*.app"
|
Show manual for the find command
|
man find
|
display all the files in the file system which belong to the user "user1"
|
find / -user user1
|
Put the absolute directory path to the current script to MY_DIR variable
|
MY_DIR=$(dirname $)
|
Recursively change the user and group of all files in "/var/cache/jenkins" to "root"
|
chown -R root:root /var/cache/jenkins
|
Report all files starting in the directories /mydir1 and /mydir2 larger than 2,000 blocks that have not been accessed in over 30 days
|
find /mydir1 /mydir2 -size +2000 -atime +30 -print
|
Find all files that aren't owned by user www-data
|
find -not -user www-data
|
Show the current UTC date in '%Y-%m-%dT%k:%M:%S%z' format
|
date -u '+%Y-%m-%dT%k:%M:%S%z'
|
Move "/usr/bin/openssl" to directory "/root/"
|
mv /usr/bin/openssl /root/
|
Find all files starting from the current directory which are owned by the user tommye
|
find . -user tommye
|
Find all directories in current directory excluding . and print a sorted list in the file a
|
find . -maxdepth 1 -type d ! -name . | sort > a
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.