Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
4 replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
source | link

Suppose that I have ten bash shell scripts: script1.sh, script2.sh, ..., script10.sh. Initially, all ten files are identical.

Now, I would like to make two changes in each script:

  1. In each file, I would like to change a particular line (say line 8) -- that is, deleting whatever is on line 8 and replacing it with a "constant" string that I specify, such as "This is line 8." This is similar to this questionthis question, but there they wanted to replace "AAA" with "BBB", whereas I would like to replace line 8 (whatever it is) with "This is line 8.".

  2. In each file, I would like to change another particular line (say line 21) and replace it with a "variable" string that I specify. For example, in script1.sh I want to change line 21 to "XYZ"; in script2.sh I want to change line 21 to "PQR"; and in script3.sh I want to change line 21 to "ABC". Essentially this is just many calls to the function in (1) above -- except that I would be making the change in one individual file rather than in all files, and that I am specifying ten different strings rather than just one. So to obtain (2) here, perhaps I would just call (1) ten different times with different parameters.

I am interested in solutions that use commonly available Linux programs like bash, vi, awk, gawk, etc.

Suppose that I have ten bash shell scripts: script1.sh, script2.sh, ..., script10.sh. Initially, all ten files are identical.

Now, I would like to make two changes in each script:

  1. In each file, I would like to change a particular line (say line 8) -- that is, deleting whatever is on line 8 and replacing it with a "constant" string that I specify, such as "This is line 8." This is similar to this question, but there they wanted to replace "AAA" with "BBB", whereas I would like to replace line 8 (whatever it is) with "This is line 8.".

  2. In each file, I would like to change another particular line (say line 21) and replace it with a "variable" string that I specify. For example, in script1.sh I want to change line 21 to "XYZ"; in script2.sh I want to change line 21 to "PQR"; and in script3.sh I want to change line 21 to "ABC". Essentially this is just many calls to the function in (1) above -- except that I would be making the change in one individual file rather than in all files, and that I am specifying ten different strings rather than just one. So to obtain (2) here, perhaps I would just call (1) ten different times with different parameters.

I am interested in solutions that use commonly available Linux programs like bash, vi, awk, gawk, etc.

Suppose that I have ten bash shell scripts: script1.sh, script2.sh, ..., script10.sh. Initially, all ten files are identical.

Now, I would like to make two changes in each script:

  1. In each file, I would like to change a particular line (say line 8) -- that is, deleting whatever is on line 8 and replacing it with a "constant" string that I specify, such as "This is line 8." This is similar to this question, but there they wanted to replace "AAA" with "BBB", whereas I would like to replace line 8 (whatever it is) with "This is line 8.".

  2. In each file, I would like to change another particular line (say line 21) and replace it with a "variable" string that I specify. For example, in script1.sh I want to change line 21 to "XYZ"; in script2.sh I want to change line 21 to "PQR"; and in script3.sh I want to change line 21 to "ABC". Essentially this is just many calls to the function in (1) above -- except that I would be making the change in one individual file rather than in all files, and that I am specifying ten different strings rather than just one. So to obtain (2) here, perhaps I would just call (1) ten different times with different parameters.

I am interested in solutions that use commonly available Linux programs like bash, vi, awk, gawk, etc.

3 Show appreciation through votes. Thanks not necessary on SO/SX http://meta.stackoverflow.com/a/3021/186664
source | link

Suppose that I have ten bash shell scripts: script1.sh, script2.sh, ..., script10.sh. Initially, all ten files are identical.

Now, I would like to make two changes in each script:

  1. In each file, I would like to change a particular line (say line 8) -- that is, deleting whatever is on line 8 and replacing it with a "constant" string that I specify, such as "This is line 8." This is similar to this question, but there they wanted to replace "AAA" with "BBB", whereas I would like to replace line 8 (whatever it is) with "This is line 8.".

  2. In each file, I would like to change another particular line (say line 21) and replace it with a "variable" string that I specify. For example, in script1.sh I want to change line 21 to "XYZ"; in script2.sh I want to change line 21 to "PQR"; and in script3.sh I want to change line 21 to "ABC". Essentially this is just many calls to the function in (1) above -- except that I would be making the change in one individual file rather than in all files, and that I am specifying ten different strings rather than just one. So to obtain (2) here, perhaps I would just call (1) ten different times with different parameters.

I am interested in solutions that use commonly available Linux programs like bash, vi, awk, gawk, etc.  

Suppose that I have ten bash shell scripts: script1.sh, script2.sh, ..., script10.sh. Initially, all ten files are identical.

Now, I would like to make two changes in each script:

  1. In each file, I would like to change a particular line (say line 8) -- that is, deleting whatever is on line 8 and replacing it with a "constant" string that I specify, such as "This is line 8." This is similar to this question, but there they wanted to replace "AAA" with "BBB", whereas I would like to replace line 8 (whatever it is) with "This is line 8.".

  2. In each file, I would like to change another particular line (say line 21) and replace it with a "variable" string that I specify. For example, in script1.sh I want to change line 21 to "XYZ"; in script2.sh I want to change line 21 to "PQR"; and in script3.sh I want to change line 21 to "ABC". Essentially this is just many calls to the function in (1) above -- except that I would be making the change in one individual file rather than in all files, and that I am specifying ten different strings rather than just one. So to obtain (2) here, perhaps I would just call (1) ten different times with different parameters.

I am interested in solutions that use commonly available Linux programs like bash, vi, awk, gawk, etc.  

Suppose that I have ten bash shell scripts: script1.sh, script2.sh, ..., script10.sh. Initially, all ten files are identical.

Now, I would like to make two changes in each script:

  1. In each file, I would like to change a particular line (say line 8) -- that is, deleting whatever is on line 8 and replacing it with a "constant" string that I specify, such as "This is line 8." This is similar to this question, but there they wanted to replace "AAA" with "BBB", whereas I would like to replace line 8 (whatever it is) with "This is line 8.".

  2. In each file, I would like to change another particular line (say line 21) and replace it with a "variable" string that I specify. For example, in script1.sh I want to change line 21 to "XYZ"; in script2.sh I want to change line 21 to "PQR"; and in script3.sh I want to change line 21 to "ABC". Essentially this is just many calls to the function in (1) above -- except that I would be making the change in one individual file rather than in all files, and that I am specifying ten different strings rather than just one. So to obtain (2) here, perhaps I would just call (1) ten different times with different parameters.

I am interested in solutions that use commonly available Linux programs like bash, vi, awk, gawk, etc.

2 thanks deleted
source | link

Suppose that I have ten bash shell scripts: script1.sh, script2.sh, ..., script10.sh. Initially, all ten files are identical.

Now, I would like to make two changes in each script:

  1. In each file, I would like to change a particular line (say line 8) -- that is, deleting whatever is on line 8 and replacing it with a "constant" string that I specify, such as "This is line 8." This is similar to this question, but there they wanted to replace "AAA" with "BBB", whereas I would like to replace line 8 (whatever it is) with "This is line 8.".

  2. In each file, I would like to change another particular line (say line 21) and replace it with a "variable" string that I specify. For example, in script1.sh I want to change line 21 to "XYZ"; in script2.sh I want to change line 21 to "PQR"; and in script3.sh I want to change line 21 to "ABC". Essentially this is just many calls to the function in (1) above -- except that I would be making the change in one individual file rather than in all files, and that I am specifying ten different strings rather than just one. So to obtain (2) here, perhaps I would just call (1) ten different times with different parameters.

I am interested in solutions that use commonly available Linux programs like bash, vi, awk, gawk, etc. Thanks for your time.

Suppose that I have ten bash shell scripts: script1.sh, script2.sh, ..., script10.sh. Initially, all ten files are identical.

Now, I would like to make two changes in each script:

  1. In each file, I would like to change a particular line (say line 8) -- that is, deleting whatever is on line 8 and replacing it with a "constant" string that I specify, such as "This is line 8." This is similar to this question, but there they wanted to replace "AAA" with "BBB", whereas I would like to replace line 8 (whatever it is) with "This is line 8.".

  2. In each file, I would like to change another particular line (say line 21) and replace it with a "variable" string that I specify. For example, in script1.sh I want to change line 21 to "XYZ"; in script2.sh I want to change line 21 to "PQR"; and in script3.sh I want to change line 21 to "ABC". Essentially this is just many calls to the function in (1) above -- except that I would be making the change in one individual file rather than in all files, and that I am specifying ten different strings rather than just one. So to obtain (2) here, perhaps I would just call (1) ten different times with different parameters.

I am interested in solutions that use commonly available Linux programs like bash, vi, awk, gawk, etc. Thanks for your time.

Suppose that I have ten bash shell scripts: script1.sh, script2.sh, ..., script10.sh. Initially, all ten files are identical.

Now, I would like to make two changes in each script:

  1. In each file, I would like to change a particular line (say line 8) -- that is, deleting whatever is on line 8 and replacing it with a "constant" string that I specify, such as "This is line 8." This is similar to this question, but there they wanted to replace "AAA" with "BBB", whereas I would like to replace line 8 (whatever it is) with "This is line 8.".

  2. In each file, I would like to change another particular line (say line 21) and replace it with a "variable" string that I specify. For example, in script1.sh I want to change line 21 to "XYZ"; in script2.sh I want to change line 21 to "PQR"; and in script3.sh I want to change line 21 to "ABC". Essentially this is just many calls to the function in (1) above -- except that I would be making the change in one individual file rather than in all files, and that I am specifying ten different strings rather than just one. So to obtain (2) here, perhaps I would just call (1) ten different times with different parameters.

I am interested in solutions that use commonly available Linux programs like bash, vi, awk, gawk, etc.

    Tweeted twitter.com/#!/StackUnix/status/348141206024376320
1
source | link