Sponsored Content
Top Forums Shell Programming and Scripting help with finding text and deleting line Post 302437513 by Franklin52 on Thursday 15th of July 2010 09:17:47 AM
Old 07-15-2010
Or:
Code:
awk -F: 'BEGIN{
  printf("Enter the email and username :")
  getline ans < "-"
  split(ans,a," ")
}
!(a[1]==$1 && a[2]==$2)
' username.txt

This User Gave Thanks to Franklin52 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed.. Add new line after finding text

I know that this my be really simple, but I'm having a hard time accomplishing it. I am trying to add a new line of text after finding a particular string of text in a file. Here's what I'm getting: sed: command garbled: N/search_string/\\new_text/ I was using "N" to add a line after the... (3 Replies)
Discussion started by: douknownam
3 Replies

2. Shell Programming and Scripting

Finding pattern & prepending a line with text

Hello Dudes, I have a task to make a unix shell script that should search for a specific TEXT in a file.If that TEXT is found, shell script should add a comment statement before that TEXT line. Ex : LINE 1 xxxxx LINE 2 xxxx CALL xxxx LINE 3 xxxx PERFORM UNTIL if i... (1 Reply)
Discussion started by: kirrushna
1 Replies

3. Shell Programming and Scripting

adding new line after finding specific text

hello i need some help here are the contents of my file. test.txt this is filename 1.mp3 http://www.url.com/filenamehashed filename 2.mp3 http://www.url.com/fileamehashed something_else.zip http://www.url.com/filenamehashed so this file has 100 of these lines filename url I would... (9 Replies)
Discussion started by: mscice
9 Replies

4. Shell Programming and Scripting

Finding a flatfile & deleting first line

I have a small script where I want to see if a file exists & then delete the first line from it. I have code to help me find if the file exists, but I am unsure as to how to then take in the answer and remove the first line from the flatfile: This is what I have so far just to output if the... (3 Replies)
Discussion started by: fatalxkiss
3 Replies

5. Shell Programming and Scripting

Finding a string in a text file and posting part of the line

What would be the most succinct way of doing this (preferably in 1 line, maybe 2): searching the first 10 characters of every line in a text file for a specific string, and if it was found, print out characters 11-20 of the line on which the string was found. In this case, it's known that there... (13 Replies)
Discussion started by: busdude
13 Replies

6. Shell Programming and Scripting

Reformatting single column text file starting new line when finding particular string

Hi, I have a single colum file and I need to reformat the file so that it creates a new line every time it come to an IP address and the following lines are corresponding rows until it comes to the next IP address. I want to turn this 172.xx.xx.xx gwpusprdrp02_pv seinwnprd03... (7 Replies)
Discussion started by: kieranfoley
7 Replies

7. Shell Programming and Scripting

Finding a match and deleting the line above to it..

Hi All, I have a file with the data: Sun is Hot Moon is cool ; -- Mon Sep 10 08:54:10 CDT 2012 -- Mon Sep 11 08:54:10 CDT 2012 -- Mon Sep 12 08:54:10 CDT 2012 revoke connect from SREE; delete from = 'SREE'; grant connect to SREE with 'fastcar8'; I want to remove the line above... (8 Replies)
Discussion started by: raosr020
8 Replies

8. Shell Programming and Scripting

Deleting text start at 2nd line....

How can I delete the first '2' characters in the 2nd line and every fourth line thereafter (Means line no.s 2, 6, 10...so on). For example if the following is my Input treieieiei trrpepepepep tyeueueue tyeueueeu tyeyeyeye tryryry tyeyey tyrtyty tytyty tututu tututututu Output... (8 Replies)
Discussion started by: cs_novice
8 Replies

9. UNIX for Dummies Questions & Answers

Deleting a pattern in UNIX without deleting the entire line

Hi I have a file: r58778.3|SOURCES={KEY=f665931a...,fw,221-705}|ERRORS={16_1:T,30_1:T,56_1:C,57_1:T,59_1:A,101_1:A,115:-,158_1:C,186_1:A,204:-,271_1:T,305:-,350_1:C,368_1:G,442_1:C,472_1:G,477_1:A}|SOURCE_1="Contig_1092402550638"(f665931a359e36cea0976db191ff60ff09cc816e) I want to retain... (15 Replies)
Discussion started by: Alyaa
15 Replies

10. Shell Programming and Scripting

Deleting all the N lines after the line in which text is found.

Hi! I want to delete N (say 10) lines after the line which text is found in a file "A".Also to delete the line in which the text is found. Only one occurrence of the search string in the file "A" The text to be deleted is in another text file "B". All the search texts in the file "B" are in... (3 Replies)
Discussion started by: shahid1632
3 Replies
rpmatch(3)						     Library Functions Manual							rpmatch(3)

NAME
rpmatch - Determines whether a response is affirmative or negative LIBRARY
Standard C Library (libc.a) SYNOPSIS
#include <stdlib.h> int rpmatch( const char *response); PARAMETERS
User input entered in response to a question that requires an affirmative or negative answer. DESCRIPTION
The rpmatch() function determines whether the string value of the response parameter matches the affirmative or negative response expres- sion as specified by the LC_MESSAGES category in the program's current locale. Both response expressions, defined in the locale, may be extended regular expressions. A possible value of the affirmative expression, yesexpr, for a English-language locale is "^([yY]|[yY][eE][sS])". This expression will match any value of the response parameter that has consists of the letter Y (in uppercase or lowercase) or the letters YES (in any mixture of uppercase and lowercase letters). EXAMPLES
The following example requests a response from the user and uses the rpmatch() function to determine if the response is affirmative or neg- ative. #include <stdlib.h> #include <stdio.h> #include <locale.h> #include <string.h> #define SLENGTH 80 main() { char str[SLENGTH], *eol; int ans; (void)setlocale(LC_ALL, ""); printf("Do you want to perform this operation: "); fgets(str, SLENGTH, stdin); if ((eol = strchr(str, ' ')) != NULL) *eol = ''; /* Replace newline with null */ else return; /* Line entered too long */ ans = rpmatch(str); if (ans == 1) printf("You responded affirmatively "); else if (ans == 0) printf("You responded negatively "); else printf("Your answer did not match "); } RETURN VALUES
A value of 1 is returned if the string value of the response parameter is matched by the affirmative expression; a value of 0 (zero) is returned if the string value of the response parameter is matched by the negative expression. If neither expression matches the string value of the response parameter, a value of -1 is returned. RELATED INFORMATION
Commands: grep(1). Functions: regcomp(3), regexec(3), setlocale(3). Files: locale(4). delim off rpmatch(3)
All times are GMT -4. The time now is 03:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy