Skip to main content
edited body
Source Link
Volker Siegel
  • 17.8k
  • 6
  • 56
  • 81

Using basic shell tollstools, it can be done like this - it may even be simpler:

paste -d . <(seq $(wc -l < new.list)) <(cut -d . -f 2- < new.list) 

I'll explain from out- to inside:

paste -d . file1 file2 

creates output lines from the files as columns. -d . sets the separator to ., which will end up behind the new numbers.

commandA <(commandB)

starts commandB and presents the output as if it where a file to read from to commandA, which expects a filename as argument. (See command substitution.)

The second argument of paste, <(cut -d . -f 2- < new.list), outputs the second column unchanged, each line from the second field on, which means starting after the ..

The first argument of paste creates the new consecutive line numbers: it firsts counts the lines using "wordcount lines": $(wc -l < new.list), and uses this number to create a sequence of numbers from 1 to the count, with seq 7.

Using basic shell tolls, it can be done like this - it may even be simpler:

paste -d . <(seq $(wc -l < new.list)) <(cut -d . -f 2- < new.list) 

I'll explain from out- to inside:

paste -d . file1 file2 

creates output lines from the files as columns. -d . sets the separator to ., which will end up behind the new numbers.

commandA <(commandB)

starts commandB and presents the output as if it where a file to read from to commandA, which expects a filename as argument. (See command substitution.)

The second argument of paste, <(cut -d . -f 2- < new.list), outputs the second column unchanged, each line from the second field on, which means starting after the ..

The first argument of paste creates the new consecutive line numbers: it firsts counts the lines using "wordcount lines": $(wc -l < new.list), and uses this number to create a sequence of numbers from 1 to the count, with seq 7.

Using basic shell tools, it can be done like this - it may even be simpler:

paste -d . <(seq $(wc -l < new.list)) <(cut -d . -f 2- < new.list) 

I'll explain from out- to inside:

paste -d . file1 file2 

creates output lines from the files as columns. -d . sets the separator to ., which will end up behind the new numbers.

commandA <(commandB)

starts commandB and presents the output as if it where a file to read from to commandA, which expects a filename as argument. (See command substitution.)

The second argument of paste, <(cut -d . -f 2- < new.list), outputs the second column unchanged, each line from the second field on, which means starting after the ..

The first argument of paste creates the new consecutive line numbers: it firsts counts the lines using "wordcount lines": $(wc -l < new.list), and uses this number to create a sequence of numbers from 1 to the count, with seq 7.

Source Link
Volker Siegel
  • 17.8k
  • 6
  • 56
  • 81

Using basic shell tolls, it can be done like this - it may even be simpler:

paste -d . <(seq $(wc -l < new.list)) <(cut -d . -f 2- < new.list) 

I'll explain from out- to inside:

paste -d . file1 file2 

creates output lines from the files as columns. -d . sets the separator to ., which will end up behind the new numbers.

commandA <(commandB)

starts commandB and presents the output as if it where a file to read from to commandA, which expects a filename as argument. (See command substitution.)

The second argument of paste, <(cut -d . -f 2- < new.list), outputs the second column unchanged, each line from the second field on, which means starting after the ..

The first argument of paste creates the new consecutive line numbers: it firsts counts the lines using "wordcount lines": $(wc -l < new.list), and uses this number to create a sequence of numbers from 1 to the count, with seq 7.