sorting | sort | LaTeX | xfig ps | |||||||||||
smart copies | awk | Scanning | ||||||||||||
hash variables assignment | sed | Convert
MS-Word |
||||||||||||
find | symbolic links | ps to pdf | ||||||||||||
fonts | color | FrameMaker |
use field 5 (numeric) in a blank-separated set of columns
Hash-variable assignment in sh
In this example the strings that are copied from the first line of
file $file may contain
backslash and parenthesis. sed and awk were difficult to use
for i in $*will work
do
eval u\=\'`head -1 $file | awk -v c=$i -f pac.awk `\'
eval site_$i\=\$u
eval echo site$i: \$site_$i
doneeval site\=\$site_1
echo $x $y 12 0 0 5 $site | pstext ...
See the manual page.
find . -type d -name "[A-z]*" | sort -r | xargs rmdir -fremoves all subdirectories below.
find . -type f | xargs rm -fremoves all files below.
find . -type f -acl '=*.*+x'finds all files with the execution bit set for everyone.
find . -type f -acl '*.*+x'finds all files with the execution bit set for someone.
find . -type f -follow -acl '*.*+x' -exec ll {} \; | awk '{if ($5 < 25000) print $9}'
finds practically all shell scripts.
find . -type f -hidden | xargs ls -la | awk '{if ($5 > 500000) print $0}'
prints all files larger than 500 kbytes down the dir tree
Find a module, search all libraries:
Example: find alpfn.o
find . -name 'lib*.a' -exec myar
{} \; |\
fgrep -e "alpfn" -e 'LIB'
with ~/bin/myar as follows
#!/bin/sh
echo "\nLIBRARY $*"
ar $*
The command list above is available as a shell script:
~hgs/bin/search-ar name
-fn spc08x14h
is an X-window toolkit option that many programs understand. Inside some programs you have to switch to alternate character sets, like in
emacs:
M-x
standard-display-european
nedit:
(menu) preferences -> Text Font
-> Font Name -> spc08x14h
nedit -geometry 760x480 -fn spc08x14h
!* >& /dev/null &
ls -l | sort -k 5n -r
sorts file list by size, largest last (key is column 5)
awk '{for ( i=3 ; i<=NF ; i++ ) printf "%s ",$i; printf "\n"}'
is a simple loop to print input fields number 3 and beyond.
awk '{if ($1 > 1980 ){printf(" %7.3f %7.3f\n",$1,$2)}}' furratpg.dat
prints those records which are from 1980 and later, columns 1 and 2
of 1,2,3 More awk's
in ~/clim/p/pgwl_plot, ~/bin/*.awk
dp=`echo $out | sed "s@$i1\(.*\)$i2.stacov\(.*\)@\1@"`
extracts the date part from a stacov file name
Case and character conversion:
echo "beba" | sed 'y/abcde/ABCDE/'
BEBA
foreach file ( euro*.txt )
mv $file `echo $file | sed "s/\(.*\)\.\(.*\)/\1.95.\2/"`
end
renames euroXX.txt to euroXX.95.txt
fgrep Selecting Oload/p/mpp/olmpp.map
| awk '{print $2}' |\
sed 's/\(.*\).o/\1.f/' | xargs -i find
. -name `echo {}`
goes thru a link-map, looks at the symbols and tries to find the associated source files in the directory tree
ls -l | awk -v PWD=$PWD \
'BEGIN{print "cd " PWD} {if ( index($1,"lr") == 1 ) print "ln -s", $11,
$9}' \
> ~/div/`echo $PWD | sed 's:/:_:g'`.
links generates commands useful to re-establish linked file structures. The output is saved in a file ~/div/${MPWD}.links where MPWD is PWD with the /-signs replaced by _
cd ~
ls -lR | awk '{ if ( NF == "1" ){CDR=$1}
else
\
{ if ( NF == "11") {print "cd", CDR;
\
print "ln -s",$11,$9 \
}
\
}
\
}' | sed 's/\(.*\):/\1/' > ~/div/all-links.lst
or
ldl
is a short special ls-type command for listing the links in the directorie(s) / file name(s) given by the arguments. The result shows the path/name of the file and the name of the link. With ldl one can copy links rather than files.
Example: copy the links that exist in directory ../A to the current
directory
ldl ../A | xargs -n2 ln -s
--
ls -lR | awk '{if ( NF == "1" ){print
"DIRECTORY::" $0} \
else
{print $9,$10,$11} }' |\
fgrep -e '::' -e '->'
finds all symbolic links below the current directory.
ls -lR | awk '{if ( NF == "1" ){CDR=$1}
\
else
{print "In",CDR,"linked",$9,$10,$11} }' |\
fgrep -e '->'
this version does not print the searched-thru dirs.
Have a look at ~hgs/bin/lsl
lsl -h
To replace a color in Image-Magick display to transparent, use Matte
function. You probably need to set
up a private color map.
xstdcmap
-best
display -map best file
Posters:
We made one Nov 1999: ~/TeX/AGU-FM99/bifrost.*
The poster is produced in A3 format originally. Use
dvips -O0.0cm,3.5cm -t a3 -o bifrost.ps bifrost
To analyze a text for correctly paired braces, use
~hgs/bin/atext file
$
To analyze a text for correctly paired Dollar signs, use
~hgs/bin/dollar-pairs file
$
The source code in each case is found in ~hgs/util/p/m
eval set aliasd\=\$\{\?${1}_alias\}
if ( $aliasd == 1 ) then
eval set alias\=\$$1_alias
|| echo bad but good
else
set alias=" "
endif
echo 'Alias site name is ->'${alias}'<-'
Now, if you
setenv WETB_alias WTZR
and call a procedure (proc) containing the code above
proc WETB
the variable $alias will carry WTZR;
but if you call it by
proc ONSA
the variable $alias will carry one blank.
Use the following settings to get white page background and reasonable
contrast:
contrast +85 or greater
brightness +40 or less
resolution 300 dpi
First quick scan, then (hi-q) scan. Don't use hi-q scan two times in
a row. With greater resolution than 300 dpi the program drops dead. Use
tif as the saving format. jpg has been observed to suffer from dropouts.
cd ~/wv
wvHTML file.doc > file.html
(installation has problems with image files and euro-characters).
We have FrameMaker and Distiller under it. Therefore
add /Frame/bin to PATH and
setenv FMHOME=/Frame
distill file.ps
mkdir /temp/$USER # once for all
( setenv HOME /temp/$USER; maker )
Setting the standard printer for use in batch printing:
mkdir ~/fminit
create file FMprinterlist containing
#!/bin/sh
cp /home/$USER/fminit/myfmprinterlist
$1
and don't forget
chmod u+x /home/$USER/fminit/FMprinterlist
Create file /home/$USER/fminit/myfmprinterlist containing
pslaser_1
or whatever your favourite printer is called. Next time you can print your document as a batch process:
fmprint document.fm
(the -p option did not work last time I tried)
fgrep -v 'cp clip' file.ps > file-u.ps
.bye