0

If I have a file like this:

foo bar
bar foo
5 foo
bar 5

and I want to change the file to look like this:

1 bar
2 foo
3 foo
4 5

How can I go about doing this?

3

How about Awk?

$ awk '{$1 = FNR} 1' file
1 bar
2 foo
3 foo
4 5

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.