Monday, September 10, 2007
Need formatting in output
$ cat fil2
090607:The rest of the line
091207:Also some text
091207:Here's some more text
[Output required]
06-09-07:The rest of the line
12-09-07:Also some text
12-09-07:Here's some more text
SED solution:
$ sed -e "s/^\(..\)\(..\)\(.*\)/\2-\1-\3/g" fil2
PERL solution:
#!/usr/bin/perl
open(FILE, "$ARGV[0]");
# replace [ by <> below
while([FILE]){
$_=~s/^(\d{2})(\d{2})(\d{2})/$2-$1-$3/;
print $_;
}
Subscribe to:
Post Comments (Atom)
© Jadu Saikia www.UNIXCL.com
No comments:
Post a Comment