use field 5 (numeric) in a blank-separated set of columns
find . -type f | Filetime -n - | awk -F\t '\!/No such file/{if($2<30){gsub(/ /,"",$1);Filetime is a perl procedure (linked to /home/hgs/perlproc/Filetime.pl)
sub(/.\//,"",$1); printf "cp ./%s /Bifrost/hgs/%s\n",$1,$1}}' > cp.batsource cp.bat
find . -type f | Filetime -n - | awk -F\t -v d=/Bifrost/hgs/ -f ft2cp.awk > cp.batusing a file ft2cp.awk
find . -type f | fgrep -v
ETERNA34 |
fgrep -v .netscape/cache |\
Filetime -f -M 31 -
> !
BU_020912/upd_since_020813.lst
will make a list of files in the directory tree younger than 31 days
To do the actual copy,
tar cfv BU_020912/BU_020912.tar `cat BU_020912/upd_since_020813.lst`
Now, this tar can be copied e.g. to CD-R
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)
PostScript conversion to pixel-based graphics
(1) Conversion with Ghostscript
cat file.ps | gs -q -sDEVICE=jpeg -sOutputFile=file.jpg -Better quality: use png This format can also be displayed in netscape etc.
cat file.ps | gs -q -sDEVICE=png256 -sOutputFile=file.png -( -r300 to get 300dpi, not the default 72dpi)
cat file.ps | gs -q -sDEVICE=png16m -sOutputFile=file.png -
cat file.ps | gs -q -sDEVICE=png16m -sOutputFile=file.png -r300 -
(2) Conversion with ImageMagick's convert
convert -quality 75 -density 300dpi file.ps file.jpg
foreach s ( `cat list.txt` )It has some nice features. For instance, the carriage-return is suppressed. The response is translated to lower-case.
echo Do section $s '? '"\c"
set ans=`sh ' read XXX ; echo $XXX ' | tr '[A-Z]' '[a-z]'`
if ( x`beak $ans` == xy ) then
echo o.k., lets do $s
endif
end
echo "$1" | sed 's/\(.\).*/\1/'that's the only line in that shell script (it works in all shells).
/usr/lib/X11/fonts/misc/fonts.aliasand other directories - search for fonts.dir and fonts.alias
/usr/lib/X11/fonts/misc/fonts.dir
find /usr/lib/X11 -name fonts.dirThe font can be displayed using the long names, e.g.
xfd -fn '-adobe-courier-medium-r-normal--8-80-75-75-m-50-hp-roman8'and they can be used in applications, e.g.
emacs -fn '-adobe-courier-medium-r-normal--8-80-75-75-m-50-hp-roman8'The first column in the fonts.dir files hint at short names, e.g.
courR08.pcf.Z -adobe-courier-medium-r-normal--8-80-75-75-m-50-iso8859-1
emacs -fn courR08
^M-x customize ->Programming -> Languages -> Perl