Skip to main content
Since < and > have special meaning in the shell, it can be confusing to use them this way; corrected the missing command substitution
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

To do this with awk you can use command like:

awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>input_file

or

awk '{gsub("file","/dev/loop"); printf "%s ", $0}' <input file>input_file

It replace file with nothing and then print /dev/loop concatenated with the number/string

To add in array you can use:

array=( $(awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <inputinput_file) file>)

To do this with awk you can use command like:

awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>

or

awk '{gsub("file","/dev/loop"); printf "%s ", $0}' <input file>

It replace file with nothing and then print /dev/loop concatenated with the number/string

To add in array you can use:

array=(awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>)

To do this with awk you can use command like:

awk '{gsub("file",""); printf "/dev/loop%s ", $0}' input_file

or

awk '{gsub("file","/dev/loop"); printf "%s ", $0}' input_file

It replace file with nothing and then print /dev/loop concatenated with the number/string

To add in array you can use:

array=( $(awk '{gsub("file",""); printf "/dev/loop%s ", $0}' input_file) )
added 75 characters in body
Source Link
Romeo Ninov
  • 19.5k
  • 5
  • 35
  • 48

To do this with awk you can use command like:

awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>

or

awk '{gsub("file","/dev/loop"); printf "%s ", $0}' <input file>

It replace file with nothing and then print /dev/loop concatenated with the number/string

To add in array you can use:

array=(awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>)

To do this with awk you can use command like:

awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>

It replace file with nothing and then print /dev/loop concatenated with the number/string

To add in array you can use:

array=(awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>)

To do this with awk you can use command like:

awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>

or

awk '{gsub("file","/dev/loop"); printf "%s ", $0}' <input file>

It replace file with nothing and then print /dev/loop concatenated with the number/string

To add in array you can use:

array=(awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>)
Source Link
Romeo Ninov
  • 19.5k
  • 5
  • 35
  • 48

To do this with awk you can use command like:

awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>

It replace file with nothing and then print /dev/loop concatenated with the number/string

To add in array you can use:

array=(awk '{gsub("file",""); printf "/dev/loop%s ", $0}' <input file>)