Skip to main content
Fixed formatting, added missing numbers
Source Link
terdon
  • 252.2k
  • 69
  • 480
  • 718

Using sed how can I replace the lines that start with a star and replace it with numbers starting from 1?

I need to replace the (*) in the fist of a list with numbers using sed for example >

this file contain a list

*linux

*computers

*labs

*questions

*linux

*computers

*labs

*questions

to >>>>

this file contain a list

1 linux
2 computers
3 labs
4 questions

linux computers labs questions II tried using

sed -e 's/*//' file.in > file.out | sed -i = file.out

sed -e 's/*//' file.in > file.out | sed -i = file.out

Using sed how can I replace the lines that start with a star and replace it with numbers starting from 1?

I need to replace the (*) in the fist of a list with numbers using sed for example >

this file contain a list

*linux

*computers

*labs

*questions

to >>>>

this file contain a list

linux computers labs questions I tried using

sed -e 's/*//' file.in > file.out | sed -i = file.out

Using sed how can I replace the lines that start with a star and replace it with numbers starting from 1?

I need to replace the (*) in the fist of a list with numbers using sed for example >

this file contain a list

*linux

*computers

*labs

*questions

to >>>>

this file contain a list

1 linux
2 computers
3 labs
4 questions

I tried using

sed -e 's/*//' file.in > file.out | sed -i = file.out
edited title
Link

how can I use sed to replace the lineslists that startbegins with (*) in a star and replace it with numbers start from 1file

added 311 characters in body
Source Link

Using sed how can I replace the lines that start with a star and replace it with numbers starting from 1?

I need to replace the (*) in the fist of a list with numbers using sed for example >

this file contain a list

*linux

*computers

*labs

*questions

to >>>>

this file contain a list

linux computers labs questions I tried using

sed -e 's/*//' file.in > file.out | sed -i = file.out

Using sed how can I replace the lines that start with a star and replace it with numbers starting from 1?

Using sed how can I replace the lines that start with a star and replace it with numbers starting from 1?

I need to replace the (*) in the fist of a list with numbers using sed for example >

this file contain a list

*linux

*computers

*labs

*questions

to >>>>

this file contain a list

linux computers labs questions I tried using

sed -e 's/*//' file.in > file.out | sed -i = file.out

added 6 characters in body
Source Link
Ketan
  • 9.4k
  • 7
  • 44
  • 57
Loading
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
Loading
Source Link
Loading