0

if someone can write a better subject, then i would be happy:D

INPUT:
201103 1 /mnt/hdd/PUB/SOMETHING
201102 7 /mnt/hdd/PUB/SOMETH ING
201103 11 /mnt/hdd/PUB/SO METHING
201104 3 /mnt/hdd/PUB/SOMET HING
201106 1 /mnt/hdd/PUB/SOMETHI NG

I NEED THIS OUTPUT:
201103 01 /mnt/hdd/PUB/SOMETHING
201102 07 /mnt/hdd/PUB/SOMETH ING
201103 11 /mnt/hdd/PUB/SO METHING
201104 03 /mnt/hdd/PUB/SOMET HING
201106 01 /mnt/hdd/PUB/SOMETHI NG

how can i add a "0" if there is only e.g.: "1" in the "day" part? [i need this date format is: YYYYMM DD]

2 Answers 2

2

You could try e.g. this:

sed -r 's/^([0-9]{6}\s)([0-9]\s)/\10\2/'
0
$ sed 's/\(\<[0-9]\>\)/0\1/' ./infile
201103 01 /mnt/hdd/PUB/SOMETHING
201102 07 /mnt/hdd/PUB/SOMETH ING
201103 11 /mnt/hdd/PUB/SO METHING
201104 03 /mnt/hdd/PUB/SOMET HING
201106 01 /mnt/hdd/PUB/SOMETHI NG

https://unix.stackexchange.com/questions/9137/sed-e-g-1-to-01-how

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.