Sponsored Content
Top Forums Shell Programming and Scripting Grep a string from input file and delete next three lines including the line contains string in xml Post 302559750 by Franklin52 on Wednesday 28th of September 2011 04:44:21 AM
Old 09-28-2011
Or you can try this approach:
Code:
awk ' -F\"
NR==FNR{a[$0]=$0;next}
/<projected value=/ && $(NF-1) in a {f=1}
/<\/projected>/ && f {f=0; next}
!f
' 1_strings myxml

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep a string in a range and delete the line

Hi, i need to delete a lines after searching a particular string but this searching should only happen after the 4th line.. basically imagine a file like this From: abcd.yahoo.com To: cdeb.yahoo.com Subject: hi all sdfsd sadasd asdasd dfsdf From: abcd.yahoo.com To:... (3 Replies)
Discussion started by: depakjan
3 Replies

2. Shell Programming and Scripting

search string in a file and retrieve 10 lines including string line

Hi Guys, I am trying to write a perl script to search a string "Name" in the file "FILE" and also want to create a new file and push the searched string Name line along with 10 lines following the same. can anyone of you please let me know how to go about it ? (8 Replies)
Discussion started by: sukrish
8 Replies

3. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

4. Shell Programming and Scripting

input a string and copy lines from a file with that string on it

i have a file1 with many lines. i have a script that will let me input a string. for example, APPLE. what i need to do is to copy all lines from file1 where i can find APPLE or any string that i specify and paste in on file 2 thanks in advance! (4 Replies)
Discussion started by: engr.jay
4 Replies

5. UNIX for Dummies Questions & Answers

Delete a line containing a string from user input

I have code that accepts input from a user, and when the user hits enter it is supposed to delete that whole line from the file. echo "Which record? " read record sed '/$record/d' file However, it does not delete it. Any help? (1 Reply)
Discussion started by: itech4814
1 Replies

6. Shell Programming and Scripting

Grep line with all string in the lines and not space.

I want to write the syntax so does not count line with no space. So currerntly it is showing lines as 5, but i want to show 4. # cat /tmp/mediacheck | sort -u | grep -vi " " | awk '{print $1}' | wc -l BA7552 BAA002 BAA003 BAA004 (6 Replies)
Discussion started by: Junes
6 Replies

7. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

8. UNIX for Advanced & Expert Users

How to find a string in a line in UNIX file and delete that line and previous 3 lines ?

Hi , i have a file with data as below.This is same file. But actual file contains to many rows. i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ? Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies

9. UNIX for Dummies Questions & Answers

Search for a string,delete the line and replace with new string in a file

Hi Everyone, I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file. I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies

10. Shell Programming and Scripting

Delete all lines except a line starting with string

Shell : bash OS : RHEL 6.8 I have a file like below. $ cat pattern.txt hello txt1 txt2 txt3 some other text txt4 I want to remove all lines in this file except the ones starting with txt . How can I do this ? (4 Replies)
Discussion started by: omega3
4 Replies
qmail-pw2u(8)						      System Manager's Manual						     qmail-pw2u(8)

NAME
qmail-pw2u - build address assignments from a passwd file SYNOPSIS
qmail-pw2u [ -/ohHuUC ] [ -cchar ] DESCRIPTION
qmail-pw2u reads a V7-format passwd file from standard input and prints a qmail-users-format assignment file. A V7-format passwd file is a series of lines. Each line has the format user:password:uid:gid:gecos:home:shell where user is an account name, uid and gid are the user id and group id of that account, and home is the account's home directory. pass- word, gecos, and shell are ignored by qmail-pw2u. If you put the output of qmail-pw2u into /var/lib/qmail/users/assign, and then run qmail-newu, qmail-lspawn will obey the assignments printed by qmail-pw2u. WARNING: After changing any users, uids, gids, or home directories in your passwd file, you must run qmail-pw2u and qmail-newu again if you want qmail-lspawn to see the changes. RULES
By default, qmail-pw2u follows the same rules as qmail-getpw. It skips user if (1) uid is zero, (2) home does not exist, (3) user does not own home, or (4) user contains uppercase letters. It then gives each remaining user control over the basic user address and all addresses of the form user-anything. A catch-all user, alias, controls all other addresses. You may change these rules by setting up files in /var/lib/qmail/users: include Allowed users, one per line. If include exists, and user is not listed in include, user is ignored. exclude Ignored users, one per line. If exclude exists, and user is listed in exclude, user is ignored. mailnames Replacement names for users. Each line has the form user:mailname1:mailname2:... The addresses mailname1 and mailname1-ext and mailname2 and so on will be delivered to user. WARNING: The addresses user and user-ext will not be delivered to user unless user is listed as one of the mailnames. A line in mailnames is silently ignored if the user does not exist. subusers Extra addresses. Each line has the form sub:user:pre: sub will be handled by home/.qmail-pre, where home is user's home directory; sub-ext will be handled by home/.qmail-pre-ext. append Extra assignments, printed at the end of qmail-pw2u's output. OPTIONS
-o (Default.) Skip user if home does not exist (or is not visible to qmail-pw2u). Skip user if home is not owned by user. -h Stop if home does not exist. This is appropriate if every user is supposed to have a home directory. Skip user if home is not owned by user. -H Do not check the existence or ownership of home. -U (Default.) Skip user if there are any uppercase letters in user. -u Allow uppercase letters in user. -cchar Use char as the user-extension delimiter in place of -. -C Disable the user-extension mechanism. -/ Use home/.qmail-/... instead of home/.qmail-... SEE ALSO
qmail-users(5), qmail-lspawn(8), qmail-newu(8), qmail-getpw(8) qmail-pw2u(8)
All times are GMT -4. The time now is 06:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy