4 added 110 characters in body
source | link

You can use branches:

sed '
  1b1
  7b1
  14b1
  16b1

  # for the rest to be left alone, branch off (or delete them with "d"):
  b

  :1
  long_command'

(note that you can also add some 20,25b1 line ranges, or /re/b1 to include lines that match the re).

Or you could use awk:

awk 'NR == 1 || NR == 7 || ... {stuff}'

Or using a hash:

awk -v l=1,7,14,16 '
  BEGIN{split(l, a, ","); for (i in a) lines[a[i]]}

  NR in lines {stuff}'

(or BEGIN{lines[1]lines[7]lines[14]lines[16]} if there aren't too many)

You can use branches:

sed '
  1b1
  7b1
  14b1
  16b1

  # for the rest to be left alone, branch off (or delete them with "d"):
  b

  :1
  long_command'

Or you could use awk:

awk 'NR == 1 || NR == 7 || ... {stuff}'

Or using a hash:

awk -v l=1,7,14,16 '
  BEGIN{split(l, a, ","); for (i in a) lines[a[i]]}

  NR in lines {stuff}'

(or BEGIN{lines[1]lines[7]lines[14]lines[16]} if there aren't too many)

You can use branches:

sed '
  1b1
  7b1
  14b1
  16b1

  # for the rest to be left alone, branch off (or delete them with "d"):
  b

  :1
  long_command'

(note that you can also add some 20,25b1 line ranges, or /re/b1 to include lines that match the re).

Or you could use awk:

awk 'NR == 1 || NR == 7 || ... {stuff}'

Or using a hash:

awk -v l=1,7,14,16 '
  BEGIN{split(l, a, ","); for (i in a) lines[a[i]]}

  NR in lines {stuff}'

(or BEGIN{lines[1]lines[7]lines[14]lines[16]} if there aren't too many)

3 added 23 characters in body
source | link

You can use branches:

sed '
  1b1
  7b1
  14b1
  16b1

  # for the rest to be left alone, branch off (or delete them with "d"):
  b

  :1
  long_command'

Or you could use awk:

awk 'NR == 1 || NR == 7 || ... {stuff}'

Or using a hash:

awk -v l=1,7,14,16 '
  BEGIN{split(l, a, ","); for (i in a) lines[a[i]]}

  NR in lines {stuff}'

(or BEGIN{lines[1]lines[7]lines[14]lines[16]} if there aren't too many)

You can use branches:

sed '
  1b1
  7b1
  14b1
  16b1

  # for the rest, branch off (or delete with "d")
  b

  :1
  long_command'

Or you could use awk:

awk 'NR == 1 || NR == 7 || ... {stuff}'

Or using a hash:

awk -v l=1,7,14,16 '
  BEGIN{split(l, a, ","); for (i in a) lines[a[i]]}

  NR in lines {stuff}'

(or BEGIN{lines[1]lines[7]lines[14]lines[16]} if there aren't too many)

You can use branches:

sed '
  1b1
  7b1
  14b1
  16b1

  # for the rest to be left alone, branch off (or delete them with "d"):
  b

  :1
  long_command'

Or you could use awk:

awk 'NR == 1 || NR == 7 || ... {stuff}'

Or using a hash:

awk -v l=1,7,14,16 '
  BEGIN{split(l, a, ","); for (i in a) lines[a[i]]}

  NR in lines {stuff}'

(or BEGIN{lines[1]lines[7]lines[14]lines[16]} if there aren't too many)

2 added 294 characters in body
source | link

You can use branches:

sed '
  1b1
  7b1
  14b1
  16b1

  # for the rest, branch off: (or delete with "d")
  b

  :1
  long_command'

Or you could use awk:

awk 'NR == 1 || NR == 7 || ... {stuff}'

Or using a hash:

awk -v l=1,7,14,16 '
  BEGIN{split(l, a, ","); for (i in a) lines[a[i]]}

  NR in lines {stuff}'

(or BEGIN{lines[1]lines[7]lines[14]lines[16]} if there aren't too many)

You can use branches:

sed '
  1b1
  7b1
  14b1
  16b1

  # for the rest, branch off:
  b

  :1
  long_command'

You can use branches:

sed '
  1b1
  7b1
  14b1
  16b1

  # for the rest, branch off (or delete with "d")
  b

  :1
  long_command'

Or you could use awk:

awk 'NR == 1 || NR == 7 || ... {stuff}'

Or using a hash:

awk -v l=1,7,14,16 '
  BEGIN{split(l, a, ","); for (i in a) lines[a[i]]}

  NR in lines {stuff}'

(or BEGIN{lines[1]lines[7]lines[14]lines[16]} if there aren't too many)

1
source | link