Sponsored Content
Top Forums Shell Programming and Scripting Help with scripting-->Inserting a line before a pattern Post 302903541 by Pradeep_1990 on Wednesday 28th of May 2014 10:02:32 AM
Old 05-28-2014
Help with scripting-->Inserting a line before a pattern

Hi Guys,

I have written the following script test.sh in Linux .

Code:
read -p "Please enter the name of the application: " DIRTOCREATE

read -p "Please enter the number of associates to be given access to svn:" COUNT

for (( i=0 ; i<$COUNT ; i++ ))

do

read -p "Enter the associate id  :" ID

echo  $ID >> result.txt

Lets assume the DIRTOCREATE = Testing and the
result.txt contains the below

12345
67891

I want to convert the contents in result.txt and Testing in the format

Testing = 12345, 67891

Finally want to insert the above line just before "[/]" in a file say access.txt which is of format

AppConfigurator = 260812, 260812, 291758, 266551
1713 = 258028, 271602, 407682, 407356
LHS = 291758, 260812

[/]

In short , the output should be ,

AppConfigurator = 260812, 260812, 291758, 266551
1713 = 258028, 271602, 407682, 407356
LHS = 291758, 260812
Testing = 12345, 67891
[/]


Doable ???

Thanks Guys

Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Inserting a line before the line which matches the patter

Hi Is there any command where we can insert a line "2|||" before every line starting with "3|" my input is as follows 1|ETG|12345 3|79.58|||GBP|| 1|ETG|12345 3|79.58|||GBP|| 1|ETG|12345 2|EN_GB||Electrogalvanize 0.5 m2 ( Renault ) 1|ETG|12345 3|88.51|||GBP|| desired output... (10 Replies)
Discussion started by: laxmi131
10 Replies

2. Shell Programming and Scripting

Inserting a line in a file after every alternate line

Friends , I have a large file and i need to insert a line after every line.I am actually unaware how to do it.Any help appreciated. My File control station *ATM* , qread $OSS.Jul13A.FI01 interval 1 intcount 1 control station *ATM* , qread $OSS.Jul13A.FI02 interval 1 intcount... (4 Replies)
Discussion started by: appu2176
4 Replies

3. Shell Programming and Scripting

Shell Scripting:Fetching content from each line with respect to pattern.

one.txt ONS.820.log:V 20Oct2010:GP ^ ^ ONS.123.log:V 21Oct2010:GP ^ ^ ONS.820.log:V 30Oct2010:GP ^ ^ want to make new file from existing one with addition. 20Oct2010 User KV001 has name tk003 with buffer- 338-1 21Oct2010 User KV003 has name tk002 with buffer- 338-2 30Oct2010 User KV002... (5 Replies)
Discussion started by: saluja.deepak
5 Replies

4. Shell Programming and Scripting

Inserting file content into a searched pattern

Hi, i have to insert the content of source.txt into the searched pattern of the file second.txt. $cat source.txt One Two Three . . $cat second.txt This is second file pattern match start here pattern match end here end of the file so the result will be like this (4 Replies)
Discussion started by: posix
4 Replies

5. Shell Programming and Scripting

Grep the word from pattern line and update in subsequent lines till next pattern line reached

Hi, I have got the below requirement. please suggest. I have a file like, Processing Item is: /data/ing/cfg2/abc.txt /data/ing/cfg3/bgc.txt Processing Item is: /data/cmd/for2/ght.txt /data/kernal/config.klgt.txt I want to process the above file to get the output file like, ... (5 Replies)
Discussion started by: rbalaj16
5 Replies

6. Shell Programming and Scripting

Commenting a specific line and inserting a new line after commented line.

Hello All, I have following file contents cat file #line=aaaaaa #line=bbbbbb #line=cccccc #line=dddddd line=eeeeee #comment=11111 #comment=22222 #comment=33333 #comment=44444 comment=55555 Testing script Good Luck! I would like to comment line line=eeeeee and insert a new line... (19 Replies)
Discussion started by: manishdivs
19 Replies

7. Shell Programming and Scripting

Inserting comma after a specific pattern

Hi Am using ksh shell I have a file like XYSDHY read write; permission; complete; DEGHLO RTERI dersa; upomxi oidewmiew; jdipowj;Now i need to insert semicolon after the BLOCK LETTER patterns and delete all blank lines. Now I need the output as XYSDHY; read write; permission;... (3 Replies)
Discussion started by: Priya Amaresh
3 Replies

8. Shell Programming and Scripting

awk to combine lines from line with pattern match to a line that ends in a pattern

I am trying to combine lines with these conditions: 1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text. 2. If condition1 is met then continue to combine lines through a line that ends with a semicolon. 3. Ignore case when matching patterns and remove any... (5 Replies)
Discussion started by: Wes Kem
5 Replies

9. Shell Programming and Scripting

Shell Scripting , need to search and print a line that contains a specific pattern

Take example of below file. abc.txt nas1:/abc/test/test1 /test nas1:/abc/test/test1/test2 /test/abc nas1:/abc/test/ Now i have a variable that contains "nas1:/abc/test/test1" value , so i need to search the above file for this variable and print only this line. ... (14 Replies)
Discussion started by: mohit_vardhani
14 Replies

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
PCSCTEST(8)							    User Manual 						       PCSCTEST(8)

NAME
pcsctest SYNOPSIS
pcsctest DESCRPTION
pcsctest runs a test on pcscd, lists the readers currently connected, and displays card information if a card is inserted. OPTIONS
None USAGE
pcsctest lists the currently connected readers and asks the user to choose one. After choosing the reader, pcsctest will ask the user to insert a card into the card reader. If this happens pcsctest will display the cards's ATR and other information. Example: The following will occur if no reader is inserted and recognized: MUSCLE PC/SC Lite Test Program Testing SCardEstablishContext : Command successful. Testing SCardGetStatusChange Once a reader is inserted and recognized the following will occur: MUSCLE PC/SC Lite Test Program Testing SCardEstablishContext : Command successful. Testing SCardGetStatusChange Please insert a working reader : Command successful. Testing SCardListReaders : Command successful. Reader 01: SCM SCR-331 CCID 0 0 Enter the reader number : 1 Waiting for card insertion : Command successful. Testing SCardConnect : Command successful. Testing SCardStatus : Command successful. Current Reader Name : CCID USB Reader 0 0 Current Reader State : 34 Current Reader Protocol : 0 Current Reader ATR Size : 9 Current Reader ATR Value : 3B E2 00 00 04 03 00 Testing SCardDisconnect : Command successful. Testing SCardReleaseContext : Command successful. PC/SC Test Completed Successfully ! SEE ALSO
pcscd(8) BUGS
MacOSX March 2003 PCSCTEST(8)
All times are GMT -4. The time now is 01:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy