Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]

share|improve this question

You could try e.g. this:

sed -r 's/^([0-9]{6}\s)([0-9]\s)/\10\2/'
share|improve this answer
$ 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

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

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .