0

I have a block of words like this, on a single line:

Id item: VALUE nom: VALUE type: VALUE path: VALUE Id item: VALUE nom: VALUE type: VALUE path: VALUE Id item: VALUE nom: VALUE type: VALUE path: VALUE

and i want to get output like this

  • Id item: VALUE nom: VALUE type: VALUE path: VALUE
  • Id item: VALUE nom: VALUE type: VALUE path: VALUE
  • Id item: VALUE nom: VALUE type: VALUE path: VALUE

Is this possible ?

0

1 Answer 1

1
sed 's/Id item/\nId item/g' file.txt | tail -n +2

This will add a new line \n to each occurrence of Id item then tail to cut the first line which is just an empty line.

5
  • thank you, it helps me. There is any caommd that parse lines one by one from input file : i want to use tail command to check last parameter ( path )
    – mzpx
    Commented Feb 17, 2016 at 11:21
  • You want to check path value in each line or for just last line?
    – jijinp
    Commented Feb 17, 2016 at 11:23
  • exactly in each line with specific type value, exmple each line with specific type check for the path
    – mzpx
    Commented Feb 17, 2016 at 11:30
  • sed -e 's/Id item/\nId item/g' | awk 'NR!=1{print $NF}'
    – jijinp
    Commented Feb 17, 2016 at 11:33
  • awk will print only last field NF which is value for the path and also NR!=1 is for not printing the first line
    – jijinp
    Commented Feb 17, 2016 at 11:34

You must log in to answer this question.

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