?

Log in

No account? Create an account

Previous Entry | Next Entry

Need formatting in output

jaduks@LOLA:~/prac$ 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:
jaduks@LOLA:~/prac$ sed -e "s/^\(..\)\(..\)\(.*\)/\2-\1-\3/g" fil2

PERL solution:
#!/usr/bin/perl
open(FILE, "$ARGV[0]");


while(<FILE>){
$_=~s/^(\d{2})(\d{2})(\d{2})/$2-$1-$3/;
print $_;
}

 

Profile

jaduks
Jadu Kumar Saikia

Latest Month

January 2008
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728293031  
Powered by LiveJournal.com
Designed by chasethestars