Bash repository
This is exactly what the title says, a bash repository containing bash one liners and all the commands I find useful in my everyday little tasks. Maybe in the future it will have sections on the left, if the content will become unmanageable, for now I'll leave it as it is; the scope of this section is to remind me of bash commands, rapidly browsing through them.
removes all files with extension different from .ogg
find . ! -name "*.ogg" -exec rm -f {} \;
pushes current path onto the dirs stack
pushd .
pops last pushed path from the dirs stack and cds to it
popd
pushed path list
dirs
l prints the file in wchich the string is, i is ignore case, r recursive
grep -lir "text" *
prints the size of all dirs in home that start with backup
find /home -name backup* -type d -exec du -h {} --max-depth=1 \;
different way to go in tail on a file
less +F logfile
check bash script syntax
bash -n scriptname
renames all images ending with JPG in jpg
for i in *.JPG; do mv $i `basename $i JPG`jpg; done
check if var is a number, only works with int
$var -eq $var
prints last command in history rather than executing it (imagine printing last touch command
instead of grepping through history when you have to touch anm apache tomcat context)
!touch:p
is the "end" of the previous command
!$
is all of the arguments to the previous command
!*
vi /etc/X11/XF86config
oops!
^6c^6C
bash history: & suppresses duplicate entries
export HISTIGNORE="&:[bf]g:exit:mplayer"
no limit to bash history
unset HISTSIZE
unset HISTFILESIZE
which flavour of linux am i on?
lsb_release -d
uname -a
cat /etc/issue
create a sequence from 001 to 100
seq -w 100
starts counting from 1 and go on until user action
yes "" | cat -n
SECONDS is a variable that can be used to track the time a function took to complete, as in:
SECONDS=0; sleep 5 ; echo "that took approximately $SECONDS seconds"
easy to understand
killall -STOP -m firefox
killall -CONT -m firefox
test this, also as ALT- and input a number
ALT-.
searching for regular expression patterns in folders names
find . -type d -regextype posix-egrep -regex "./gwt-([0-9].[0-9].[0-9])"
port 8080 is opened but what process is it related to?
lsof -i :8080