About
Wax Wolf Musings
A weblog what a wax wolf muses with.
Taper Wickel
tpoisoned@waxwolf.com
Of course, mail to that account will just be killfiled, like as not.
Categories
Visit the mostly-mirror LiveJournal.
Subscribe
Subscribe to a syndicated feed of
my weblog, brought to you by the wonders of RSS.
Buttonblock:
Perhaps you would like to buy me an item from my wishlist at
amazon.com, ThinkGeek, or Froogle.
Or go to My cafépress store to buy Great Huge Garamond W products.
Donate money via PayPal:
|
One-liner shell scripts
I needed to back-date a bunch of files at work. Each file had a date in it like "Apr 4" or "Apr 23"; the back-dating had to match that date.
I ended up with two one-line shell scripts like the following:
for i in *.txt ; do j=`awk 'BEGIN { do { l = getline; match($0, /Apr [0-9],/) ; s = substr($0,RSTART+4,RLENGTH-5) } while ((s !~ /[0-9]/) && (l !=0)) ; print s ; close(l)}' $i` ; if [[ $j == [0-9] ]] ; then k=`echo "2003040 $j 1100" | sed 's/ //g'` ; touch -t $k $i ; fi ;done
(The other matched for two digits before the comma.)
I decided to do this as a shell-and-awk script because I thought doing it in perl would be too complicated. :-P
Posted at 7:54:54 pm (2452752.49646)
[/computers/]
#
|
Archives:
March
2024 |
S |
M |
T |
W |
T |
F |
S |
|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
|
Feb
Apr
|
Search this blog:
Search the blogs I read:
|