Sponsored Content
Top Forums Shell Programming and Scripting Search text and replace line next to it Post 302799191 by chingupt on Friday 26th of April 2013 02:30:52 AM
Old 04-26-2013
I did search but was not able to find a specific solution.
Code:
awk ' zap==1 {print "user input"; zap=0; next} /my pattern/ {zap=1; print $0; next} {print $0} '  infile > newfile

but issue comes when i try taking an input from user.
Code:
awk ' zap==1 {print $1; zap=0; next} /my pattern/ {zap=1; print $0; next} {print $0} '  infile > newfile

i get $1 in my file.

Last edited by Franklin52; 04-26-2013 at 03:31 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search and replace multi-line text in files

Hello I need to search for a mult-line text in a file exfile1 and replace that text with another text. The text to search for is in exfile2 and the replacement text is in exfile3. I work with kornshell under AIX and need to do this with a lot of files. (the file type is postscript and they need... (10 Replies)
Discussion started by: marz
10 Replies

2. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

3. UNIX for Dummies Questions & Answers

search and replace a specific text in text file?

I have a text file with following content (3 lines) filename : output.txt first line:12/12/2008 second line:12/12/2008 third line:Y I would like to know how we can replace 'Y' with 'N' in the 3rd line keeping 1st and 2nd lines same as what it was before. I tried using cat output.txt... (4 Replies)
Discussion started by: santosham
4 Replies

4. UNIX for Dummies Questions & Answers

how can search a String in one text file and replace the whole line in another file

i am very new to UNIX plz help me in this scenario i have two text files as below file1.txt name=Rajakumar. Discipline=Electronics and communication. Designation=software Engineer. file2.txt name=Kannan. Discipline=Mechanical. Designation=CADD Design Engineer. ... (6 Replies)
Discussion started by: kkraja
6 Replies

5. UNIX for Advanced & Expert Users

Search Parameter in first line and replace next line content

Hi, I need help. I have XML file as below <a n="infoLevel"> <v s="true"/> </a> <a n="localAddr"> <v s="server.host.com"/> </a> <a n="ListenPort"> <v s="21111"/> </a> I need to find variable "ListenPort" in line and then replace... (4 Replies)
Discussion started by: rdtrivedi
4 Replies

6. Shell Programming and Scripting

Search and replace text

Hello, I am trying to search and replace but I don't know how to do it. My simple knowlegde in search and replace using sed is not helping me at all. File: its a cause value #22: dfg ggg Cause value #1: aasfa fasdf asfa value #22: affg gggg Basically i want to replace the... (6 Replies)
Discussion started by: balan1983a
6 Replies

7. Shell Programming and Scripting

perl search and replace - search in first line and replance in 2nd line

Dear All, i want to search particular string and want to replance next line value. following is the test file. search string is tmp,??? ,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50 tmp,123 --- if match tmp,??? then... (3 Replies)
Discussion started by: arvindng
3 Replies

8. UNIX for Dummies Questions & Answers

VIM search and replace with line breaks in both the target and replacement text

Hi, Ive spent ages trying to find an explanation for how to do this on the web, but now feel like I'm :wall: I would like to change each occurence (there are many within my script) of the following: to in Vim. I know how to search and replace when it is just single lines... (2 Replies)
Discussion started by: blueade7
2 Replies

9. Shell Programming and Scripting

Search and Replace a text if the line contains a pattern

My text file looks like below . . . abcdefghi jklmnop $Bad_ptrq_GTS=rcrd_ip.txt $Bad_abcd_REJ=rcrd_op.txt ghijklm $Bad_abcd_TYHS=rcrd_op.txt abcgd abcdefghi jklmnop $Bad_ptrq_GTS=rcrd_ip.txt (2 Replies)
Discussion started by: machomaddy
2 Replies

10. Shell Programming and Scripting

Multiple line search, replace second line, using awk or sed

All, I appreciate any help you can offer here as this is well beyond my grasp of awk/sed... I have an input file similar to: &LOG &LOG Part: "@DB/TC10000021855/--F" &LOG &LOG &LOG Part: "@DB/TC10000021852/--F" &LOG Cloning_Action: RETAIN &LOG Part: "@DB/TCCP000010713/--A" &LOG &LOG... (5 Replies)
Discussion started by: KarmaPoliceT2
5 Replies
VOS_ZAP(1)						       AFS Command Reference							VOS_ZAP(1)

NAME
vos_zap - Removes a volume from its site without writing to the VLDB SYNOPSIS
vos zap -server <machine name> -partition <partition name> -id <volume ID> [-force] [-backup] [-cell <cell name>] [-noauth] [-localauth] [-verbose] [-encrypt] [-noresolve] [-help] vos z -s <machine name> -p <partition name> -i <volume ID> [-f] [-b] [-c <cell name>] [-noa] [-l] [-v] [-e] [-nor] [-h] DESCRIPTION
The vos zap command removes the volume with the specified volume ID from the site defined by the -server and -partition arguments, without attempting to change the corresponding Volume Location Database (VLDB) entry. If removing the volume can possibly result in incorrect data in the VLDB, a warning message is displayed. The -force flag removes a volume even if it cannot be "attached" (brought online), which can happen either because the volume is extremely damaged or because the Salvager functioned abnormally. Without this flag, this command cannot remove volumes that are not attachable. See also CAUTIONS. To remove the specified read/write volume's backup version at the same time, include the -backup flag. CAUTIONS
Do not use this command as the standard way to remove a volume, as it is likely to put the VLDB out of sync with the volumes on servers. Use the vos remove command instead. This command is useful in situations where it is important to delete the volume, but for some reason the VLDB is unreachable -- for example, because the Volume Location Server is unavailable. The issuer can remove the VLDB entry later with the vos remove or vos delentry command, or it is removed automatically when the vos syncserv and vos syncvldb commands run. To remove a read-only site defined in the VLDB by mistake, before a copy actually exists at the site, use the vos remsite command. To remove an entire VLDB entry without affecting volumes at their sites, use the vos delentry command. Do not use the -force flag if the volume is online, but only when attempts to remove the volume with the vos remove or the vos zap command have failed, or the volume definitely cannot be attached. After using the -force flag, make sure that the volume's VLDB entry is also removed (issue the vos delentry command if necessary). Adding the -force flag makes the command take considerably longer -- about as long as a salvage of the relevant partition -- since the Volume Server examines all inodes on the partition for traces of the volume. OPTIONS
-server <server name> Identifies the file server machine from which to remove the volume. Provide the machine's IP address or its host name (either fully qualified or using an unambiguous abbreviation). For details, see vos(1). -partition <partition name> Identifies the partition (on the file server machine specified by the -server argument) from which to remove the volume. Provide the partition's complete name with preceding slash (for example, "/vicepa") or use one of the three acceptable abbreviated forms. For details, see vos(1). -id <volume ID> Specifies the volume ID number of the volume to remove, which can be of any of the three types. The volume name is not acceptable. -force Removes the volume even though it cannot be attached (brought online). Use only after the failure of previous attempts to remove the volume by using the vos remove command or the vos zap command without this flag. -backup Removes the backup version of the read/write volume specified by the -id argument. Do not use this flag if the -id argument identifies a read-only or backup volume. -cell <cell name> Names the cell in which to run the command. Do not combine this argument with the -localauth flag. For more details, see vos(1). -noauth Assigns the unprivileged identity "anonymous" to the issuer. Do not combine this flag with the -localauth flag. For more details, see vos(1). -localauth Constructs a server ticket using a key from the local /etc/openafs/server/KeyFile file. The vos command interpreter presents it to the Volume Server and Volume Location Server during mutual authentication. Do not combine this flag with the -cell argument or -noauth flag. For more details, see vos(1). -verbose Produces on the standard output stream a detailed trace of the command's execution. If this argument is omitted, only warnings and error messages appear. -encrypt Encrypts the command so that the operation's results are not transmitted across the network in clear text. This option is available in OpenAFS versions 1.4.11 or later and 1.5.60 or later. -noresolve Shows all servers as IP addresses instead of the DNS name. This is very useful when the server address is registered as 127.0.0.1 or when dealing with multi-homed servers. This option is available in OpenAFS versions 1.4.8 or later and 1.5.35 or later. -help Prints the online help for this command. All other valid options are ignored. EXAMPLES
The following example removes the volume with volume ID 536870988 from the /vicepf partition of the file server machine "fs6.abc.com", without noting the change in the VLDB. % vos zap -server fs6.abc.com -partition f -id 536870988 PRIVILEGE REQUIRED
The issuer must be listed in the /etc/openafs/server/UserList file on the machine specified with the -server argument and on each database server machine. If the -localauth flag is included, the issuer must instead be logged on to a server machine as the local superuser "root". SEE ALSO
vos(1), vos_delentry(1), vos_remove(1), vos_remsite(1) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2014-04-08 VOS_ZAP(1)
All times are GMT -4. The time now is 07:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy