my nature, when it needs something;
-takes it now... (nothing wrong in that)
UNIX: out it came of AT&T Bell-Laboratories
I want to emphasize on the fact, that they
didn't need to know much to make themselves happy...
and they had really no clue as to what stalling and halting-
problems their programs would lead to in the future...
In short: they didn't care!
in glowing green depicts the program
in glowing green depicts the effects on stdout
in (sh), it looks something like:
(i=1
while : ;do
if [ $i -gt 8 ];then
break
fi
echo $i
i=$(dc -e"$i 1+p")
done)
1
2
3
4
5
6
7
8
but what if... you wanted to see what you did
before you did it? You don't want to test
a field without first (at least) trying in
reducing "risk". (whatever that means...)
here the one and only example ever on compilation via
echo / sed / awk,
[1]-using echo statements like above to compile for further execution,
[2]-previewing sed statements with ( Y ),
and using ( Y- ) WARNING:
the output of its cousin ( Y ),
is the latter content of the file... so... if it is empty
you reduce the file to a smoldering pit of ash!
to change with "any command" some files inplace
-UNIX-style! yeah... ->whatever that means
[3]-short awk example
[1]
a(){(i=1
while : ;do
if [ $i -gt 8 ];then
break
fi
echo "#rm -rf $i #a very 'dangerous' command"
i=$(dc -e"$i 1+p")
done)}
a; #eye.
#rm -rf 1 #a very 'dangerous' command
#rm -rf 2 #a very 'dangerous' command
#rm -rf 3 #a very 'dangerous' command
#rm -rf 4 #a very 'dangerous' command
#rm -rf 5 #a very 'dangerous' command
#rm -rf 6 #a very 'dangerous' command
#rm -rf 7 #a very 'dangerous' command
#rm -rf 8 #a very 'dangerous' command
to execute the previous thing, pipe it to your (sh)!
a |sh #run.
# it won't hurt to run it actually, because the lines
# are ignored... because of #
I gotta say: very handy with ssh, where you normally
have to 'keep in mind', that your shell expands every
new invocation all the "'$()>< and so on's...
a |ssh root@example.com sh #and voila
[2]
t(){(umask 077;v=$(mktemp);echo "$v")}
TMP=$(t);echo >&2 " +tmp-file: $TMP" #a temporary file...
cat >$TMP <<EOF
a.txt
b.txt
c.txt
d.txt
e.txt
EOF
# echo the old contents of $TMP
#Y $TMP cat
# echo the old contents of $TMP
#Y $TMP sed
# compile a command-chain to change the extensions to some X
Y $TMP sed 's/\(.*\)\.txt/mv \1.txt \1.X/'
# change Y to Y- and the file gets replaced inplace.
# (a feeling very unpleasant when you know, that
# you have lost all control... but, is it?)
the temporary file location is printed to another channel (stderr/2),
it will change in your time and; try to clean it up again... will you?
mv a.txt a.X
mv b.txt b.X
mv c.txt c.X
mv d.txt d.X
mv e.txt e.X
[3]
you will have to come up with something of your own...
maybe try to look here?
.
.
.
ah, whatever... one last big example with awk syntax:
# some imaginary files here (inside a funny imaginary file)
a(){ cat <<EOF
report.txt
cat.ascii
censored-stuff.ascii
EOF
}
# the very first use case of the internet... nudes;
# We try to be grown-ups now... so everyone forgot that part.
a |awk '{ print "Y "$0" sed \"s;(C) FRECHES COPYRIGHT;;g\"" }' #|sh
# nonono... you'll probably only make yourself some trouble running this...
a |awk '{ print "Y- "$0" sed \"s;(C) FRECHES COPYRIGHT;;g\"" }' #|sh
# here too, warned ya.
Y report.txt sed "s;(C) FRECHES COPYRIGHT;;g"
Y cat.ascii sed "s;(C) FRECHES COPYRIGHT;;g"
Y censored-stuff.ascii sed "s;(C) FRECHES COPYRIGHT;;g"
Y- report.txt sed "s;(C) FRECHES COPYRIGHT;;g"
Y- cat.ascii sed "s;(C) FRECHES COPYRIGHT;;g"
Y- censored-stuff.ascii sed "s;(C) FRECHES COPYRIGHT;;g"