for f in $(ls); do move $f ${f%.txt}; done
for f in $(ls); do move "$f" "${f}.txt"; done
header=$(grep . "$f" | head -n1)
${path//'/'/'\/'}
e.g.
path="/etc/apt/sources.list"; echo ${path//'/'/'\/'}
returns
\/etc\/apt\/sources.list
for f in $(ls); do sed 's/A/B/g' < $f > tmp; move tmp "$f"; done
cd ~/.nano
for f in $(ls); do sed 's/color brightwhite/color brightgreen/g' < $f > tmp; move tmp $f; done
for f in $(ls); do sed 's/color brightyellow/color brightgreen/g' < $f > tmp; move tmp $f; done
for f in $(ls); do sed 's/color white/color green/g' < $f > tmp; move tmp $f; done
for f in $(ls); do sed 's/color yellow/color green/g' < $f > tmp; move tmp $f; done
Preview all styles for lexer 'sh', formatter 'terminal256'
styles="monokai manni perldoc borland colorful default murphy vs trac tango fruity autumn bw emacs pastie friendly native";\
for s in $styles; do echo; echo "$s:"; tail ~/.bashrc | pygmentize -f 256 -l sh -O style=$s; done
Use pygmentize with lexer 'sh', formatter 'terminal256' in combination with 'less -R'
pygmentize -f terminal256 -l sh -F whitespace:spaces=True,tabs=True -O style=borland ~/.bashrc | less -R
grep TEXT $(find -maxdepth 1 -type f)
e.g. convert SVGs to PNGs:
for img in *svg; do base=`basename $img .svg`; convert "$img" "$base.png"; done;
pdfnup <sourcefile> --nup 2x3 --frame true --delta "1cm 1cm" --scale 0.91
use mountpoint command to see if a directory is a mount point e.g.
if ! mountpoint -q /mnt/backup; then
mount /mnt/backup
fi
or use grep -c (count) and mount e.g.
if [ $(mount | grep -c /mnt/backup) != 1 ]; then
mount /mnt/backup
fi
for login shell: bash reads first /etc/profile for values that are defined for all users. afterwards it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
for non-login shell: If you start another shell within the login shell (yes that's possible), the second one is a non-login shell. it will not read named start-up files but searches non-login start-up script from user's home directory instead. with bash this is called ~/.bashrc.
to avoid specifying same values in two places, make the login-shell start-up script ~/.bash_profile includes the ~/.bashrc at the end of its execution. to implement include following into your ~/.bash_profile:
if [ -f ~/.bashrc ]; then
. ~/.bashrc;
fi
my current setup:
- system-wide config in /etc/profile
- user config (login) in ~/.profile (no ~/.bash_profile -> this is important, otherwise ~/.profile would not be read)
- user config (non-login) in ~/.bashrc, which is also executed from ~/.profile
- manually written user config for environment variable in ~/.bash_environment, which is executed from ~/.bashrc
- manually written user config for aliases in ~/.bash_aliases, which is executed from ~/.bashrc
to add environment variables add the following line in ~/.bash_environment
export VARNAME=VALUE
or to append a value to an existing variable
export VARNAME=$VARNAME:VALUE
to add an alias add the following line in ~/.bash_aliases
alias ALIASNAME='COMMAND'
e.g.
alias ll='ls -l'
show current shell
$ echo $SHELL
list installed shells
$ cat /etc/shells
change login shell
$ chsh
install the 'sshfs' package, then add your user to the fuse group
$ sudo adduser <username> fuse
then restart the session, and create a mountpoint with
$ sshfs <username>@host:hostpath localpath
if a user or group on the host does not exist on the client, you can map the file permissions to another user/group. use
$ sshfs <username>@host:hostpath localpath -o idmap=user -o uid=<userid> -o gid=<groupid>
the id command is useful in this case:
$ sshfs <username>@host:hostpath localpath -o idmap=user -o uid=$(id -u) -o gid=$(id -g)
First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:
a@A:~> ssh-keygen -t rsa
Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):
a@A:~> ssh b@B mkdir -p .ssh
Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
From now on you can log into B as b from A as a without password
http://linuxproblem.org/art_9.html
install 'shntool' ('flac' and 'cuetools' will get installed too) and split with
cuebreakpoints sample.cue | shnsplit -o flac sample.flac
for ape install 'monkeys-audio' (from debian-multimedia) and split with
cuebreakpoints sample.cue | shnsplit -o ape sample.ape
install 'shntool' and 'monkeys-audio' (from debian-multimedia) convert with
shntool conv -o flac *.ape
or
shnconv -o flac *.ape
- update-alternatives
for the GUI browser
sudo update-alternatives --config x-www-browser
sudo update-alternatives --config gnome-www-browser
for the cli browser
sudo update-alternatives --config www-browser
xdg-open and sensible-browser should open the selected browser now
- desktop environment defaults
Xfce4: xfce4-settings
(Preferred Applications)
Gnome: gnome-control-center
(System Settings -> Details -> Default Applications)
KDE: systemsettings
(KDE System Settings -> Applications)
set the browser for text/html and application/xhtml+xml
Kupfer and Thunderbird/Icedove use the Gnome setting, Yakuake uses the KDE setting.
- BROWSER environment variable
you can also set the BROWSER environment variable, which is used as the first choice in sensible-browser
- /etc/mailcap
add your browser in ~/.mailcap or in /etc/mailcap.order
swaks \
--to 'ping@tools.mxtoolbox.com' \
--from 'FROM' \
--server 'smtp.world4you.com' \
--auth 'LOGIN' \
--auth-user 'FROM' \
--auth-password 'PASSWORD' \
-tls