At some point, I wrote. “This page never seems to age, …” it just contains some idioms I like to use in my .login and/or .bashrc files. I don’t do this so often as when I started the page but the MAC keeps it in the house, and I have installed cygwin on nearly all my windows systems. However, microsoft implemented bash on windows 10 and so things finally changed. …
C:
cd /mnt/c
Aliases
alias whence="type -p " export PS1="B$ "
Paths
contains() { # $1 must be set and grep must be in the PATH echo $1 | grep $2 > /dev/null code=$? return $code } for directory in /usr/local/bin /usr/java/bin do contains $PATH $directory if [ $? ! = 0 ] then PATH=$directory:$PATH fi done
Fashions change
for directory in /usr/local/bin /usr/java/bin;do contains $PATH $directory [ $? ! = 0 ] && PATH=$directory:$PATH done
This can be done for any PATH like variable such as MANPATH & LD_LIBRARY_PATH. The code above doesn’t test for an empty variable because it is manipulating the $PATH, which is unlikely to be unset. Here is some code that performs the test. NB If we want to add to the MANPATH, we need to capture the default values, or do with the Cobalt Linux, since ti treats the man search path differently depending upon if $MANPATH is set or not.
if [ -z $MANPATH ] then # if MANPATH is unset get it MANPATH=`cat /etc/man.config | \ awk '$1 == path {print $2;}' path=MANPATH | \ tr '\n' ":" fi contains $MANPATH ${POSTGRES_HOME}/man if [ $? != 0 ] then MANPATH=${POSTGRES_HOME}/man fi export MANPATH
I should check that BASH implements the -z test in the same way as the Korn shell.
ksh
If I am going to use it
ENV=${HOME}/.kshrc EDITOR=vi
File Scanner
A file scanner
#!/usr/bin/ksh typeset -u input while read input do print "$input" # if you like to add line to some file, then # print some >> somefile # single > is overwrite = file include only the lastline done
Links
- gnu.org on Arrays, bash now does arrays
- man basename at linux.die.org
- String Manipulation, I always forget this
This was originally posted to davelevy.dyndns.info in 2010.
Much of this is now on github in my ubuntu-tools repo.
hey there and thank you for your information – I’ve definitely picked up something new from right here. I did however expertise some technical points using this site, since I experienced to reload the site many times previous to I could get it to load properly. I had been wondering if your web host is OK? Not that I am complaining, but sluggish loading instances times will often affect your placement in google and could damage your high quality score if advertising and marketing with Adwords. Well I am adding this RSS to my e-mail and could look out for much more of your respective interesting content. Make sure you update this again soon..
My brother recommended I might like this web site. He was totally right. This post truly made my day. You can not imagine simply how much time I had spent for this info! Thanks!
Hey, great article. Bookmarked the site 😉