
Terminal - Commands using bash - 41 results
find /dev/ -name random -exec bash -c '[ -r $0 -a -w $0 ] && dd if=$0 | sort | dd of=$0' {} \;
This is sample output - yours may be different.
find /path/to/images -name '*.JPG' -exec bash -c 'mv "$1" "${1/%.JPG/.jpg}"' -- {} \;
This is sample output - yours may be different.
Recursively rename .JPG to .jpg using standard find and mv. It's generally better to use a standard tool if doing so is not much more difficult.
cd /usr/home && for i in *;do chsh -s bash $i;done
This is sample output - yours may be different.
This command will set bash as the default shell for all users in a FreeBSD system.
printf "%s\n" !(pattern) ## ksh, or bash with shopt -s extglob
This is sample output - yours may be different.
There's no need for ls or grep; printf is builtin to most modern shells
in bash hit "tab" twice and answer y
This is sample output - yours may be different.
seq 4|xargs -n1 -i bash -c "echo -n 164.85.216.{} - ; nslookup 164.85.216.{} |grep name"|tr -s ' ' ' '|awk '{print $1" - "$5}'|sed 's/.$//'
This is sample output - yours may be different.
164.85.216.1 - station1.domain.biz
164.85.216.2 - station2.domain.biz
164.85.216.3 - station3.domain.biz
164.85.216.4 - station4.domain.biz
dpkg --get-selections | cut -f1 | while read pkg; do dpkg -L $pkg | xargs -I'{}' bash -c 'if [ ! -d "{}" ]; then echo "{}"; fi' | tr '\n' '\000' | du -c --files0-from - | tail -1 | sed "s/total/$pkg/"; done
This is sample output - yours may be different.
176 acl
44 acpi
396 acpi-support
32 acpi-support-base
108 acpid
524 adduser
408 akonadi-server
2416 akregator
388 alsa-base
1840 alsa-utils
1860 amor
96 anacron
120 apmd
4512 apt
104 apt-file
376 apt-utils
140 apt-xapian-index
9184 aptitude
112 at
104 avahi-autoipd
252 avahi-daemon
260 base-files
100 base-passwd
du: cannot access `diverted by dash to: /usr/share/man/man1/sh.distrib.1.gz': No such file or directory
du: cannot access `diverted by dash to: /bin/sh.distrib': No such file or directory
Calculates the size on disk for each package installed on the filesystem (or removed but not purged). This is missing the
| sort -rn
which would put the biggest packges on top. That was purposely left out as the command is slightly on the slow side
Also you may need to run this as root as some files can only be checked by du if you can read them ;)
This is sample output - yours may be different.
Display man page in plain text
bash -x test.sh 2>&1 | tee out.test
This is sample output - yours may be different.
Sends both stdout and stderr to the pipe which captures the data in the file 'out.test' and sends to stdout of tee (likely /dev/tty unless redirected). Works on Bourne, Korn and Bash shells.
This is sample output - yours may be different.
* in bash-shell You can capture the current commandline to a text-editor:
* simply press: CTRL+x+e
* Your current commandline will pe put into Your default text-editor (export EDITOR=vim)
find . -name '*'.tiff -exec bash -c "mogrify -format jpg -quality 85 -resize 75% {} && rm {}" \;
This is sample output - yours may be different.
Simple command to convert a large number of images into jpeg-format. Will delete originals after conversion.
find . -name "*.gz" | xargs -n 1 -I {} bash -c "gunzip -c {} | sort | gzip -c --best > {}.new ; rm {} ; mv {}.new {}"
This is sample output - yours may be different.
I used this because I needed to sort the content of a bunch of gzipped log files. Replace sort with something else, or simply remove sort to just rezip everything
This is sample output - yours may be different.
This is sample output - yours may be different.
+ start-stop-daemon -k 002 -S -p/var/run/jetty.pid -c jetty -d /usr/share/jetty6 -b -m -a /usr/lib/jvm/java-1.5.0-sun/bin/java -- -DSTART=/usr/share/jetty6/etc/start.config -Xmx256m -Djava.awt.headless=true -DDEBUG -Djetty.port=8070 -Xms512m -Xmx2048m -XX:PermSize=384m -XX:MaxPermSize=512m -Djetty.home=/usr/share/jetty6 -Djava.io.tmpdir=/var/cache/jetty6 -jar /usr/share/jetty6/start.jar /etc/jetty6/jetty-logging.xml /etc/jetty6/jetty.xml
process already running.
+ exit 0
Display commands and their arguments as they are executed. Useful for debugging shell scripts.
bash -x ./post_to_commandlinefu.sh
This is sample output - yours may be different.
bash -x ./post_to_commandlinefu.sh bash -x ./post_to_commandlinefu.sh
+ COMMAND='bash -x ./post_to_commandlinefu.sh'
+ echo 'command is bash -x ./post_to_commandlinefu.sh'
command is bash -x ./post_to_commandlinefu.sh
+ '[' 'bash -x ./post_to_commandlinefu.sh' = '' ']'
+ SESSIONFILE=./.c
+ LOGINURL=http://www.commandlinefu.com/users/signin
+ EDITURL=http://www.commandlinefu.com/commands/edit
++ dirname ./.c
++ basename ./.c
+ find . -name .c -mtime +1 -exec rm '{}' ';'
+ '[' '!' -f ./.c ']'
+ echo -n 'Enter commandlinefu username: '
Enter commandlinefu username: + read USERNAME
+ echo -n 'Enter commandlinefu password: '
Enter commandlinefu password: + read -s PASSWORD
+ echo
+ wget -O - --save-cookies ./.c --keep-session-cookies --post-data 'username=&password=&remember=on&submit=Let me in!' http://www.commandlinefu.com/users/signin
+ echo -n 'Enter summary (required): '
Enter summary (required): + read SUMMARY
runs a bash script in debugging mode
++ echo runs a bash script in debugging mode
++ cut -c1-154
+ SUMMARY='runs a bash script in debugging mode'
++ echo bash -x ./post_to_commandlinefu.sh
++ cut -c1-254
+ COMMAND='bash -x ./post_to_commandlinefu.sh'
+ echo 'post-data is command=bash -x ./post_to_commandlinefu.sh&summary=runs a bash script in debugging mode&submit=Save'
post-data is command=bash -x ./post_to_commandlinefu.sh&summary=runs a bash script in debugging mode&submit=Save
+ wget -O - --load-cookies ./.c --post-data 'command=bash -x ./post_to_commandlinefu.sh&summary=runs a bash script in debugging mode&submit=Save&' http://www.commandlinefu.com/commands/edit
+ rm -f browse edit
+ rm -f '*17274*'
^r in bash begins a reverse-search-history with command completion
This is sample output - yours may be different.
(reverse-i-search)`las': last -a | head
In the sample output, I pressed ctrl+r and typed the letters las. I can't imagine how much typing this has saved me.