Sponsored Content
Top Forums Shell Programming and Scripting retaining only the second line with a pattern and deleting all others Post 302568934 by bartus11 on Friday 28th of October 2011 04:52:19 PM
Old 10-28-2011
Try:
Code:
awk 'tolower($0)~"rage"&&++i==2||tolower($0)!~"rage"' input

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

prom in deleting a pattern

hi guys, i have a directory.inside that so many directories and files are there.i want to search the complete directory for a pattern in all the .txt files.if i will find that pattern then i want to delete that pattern from that file. please help me out. i want it urgent (18 Replies)
Discussion started by: suvendu4urs
18 Replies

2. UNIX for Dummies Questions & Answers

find pattern delete line with pattern and line above and line below

I have a file that will sometimes contain a pattern. The pattern is this: W/D FRM CHK 00 I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below. (1 Reply)
Discussion started by: nickg
1 Replies

3. Shell Programming and Scripting

find pattern, delete line with pattern and line above and line below

I have a file that will sometimes contain a pattern. The pattern is this: FRM CHK 0000 I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below. (4 Replies)
Discussion started by: nickg
4 Replies

4. Shell Programming and Scripting

deleting a pattern from a file

say i have a file with the following contents 0x20 0x20 0xc23886 > 0xc12354 > 0xc567555555 i want to delete "> " pattern and keep the rest of the file (6 Replies)
Discussion started by: lassimanji
6 Replies

5. Shell Programming and Scripting

Searching a pattern in file and deleting th ewhole line containing the pattern

Hi All, Please can someone assist in the script I have made that searches a pattern in a file and delete the whole line containing the pattern. #!bin/sh # The pattern that user want to add to the files echo "Enter the pattern of the redirect" read value # check if the user has... (1 Reply)
Discussion started by: Shazin
1 Replies

6. Shell Programming and Scripting

Deleting pattern without removing line

I am trying to delete a pattern without removing line. I searched a lot in this forum and using those I could come up with sed command but it seems that command does not work. Here's how my file looks like: 1 ./63990 7 1171 ./63990 2 2425 ./63990 9 2539 ./63990 1 3125 ./63990 1 10141... (7 Replies)
Discussion started by: shoaibjameel123
7 Replies

7. 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

8. 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

9. 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

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
conv(3) 						     Library Functions Manual							   conv(3)

NAME
toascii, tolower, _tolower, toupper, _toupper - Translate characters LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <ctype.h> int toascii( int c); int tolower( int c); int _tolower( int c); int toupper( int c); int _toupper( int c); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: toascii(), tolower(), _tolower(), toupper(), _toupper(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the character to be converted. DESCRIPTION
The toascii(), tolower(), _tolower(), toupper(), and _toupper() functions translate all characters, including multibyte characters, to their specified character values. The toascii() function converts its input to a 7-bit ASCII character. The tolower() function takes an int value that can be represented as an unsigned char or the value of EOF (defined in the stdio.h header file) as its input. When the input of the tolower() function expresses an uppercase letter, and there exists a corresponding lowercase letter (as defined by character type information in the program locale category LC_CTYPE), the corresponding lowercase letter is returned. All other input val- ues in the domain are returned unchanged. The tolower() function has as its domain the range -1 through 255. In the C locale, or in a locale where case-conversion information is not defined, the tolower() function determines the case of characters according to the rules of the Portable Character Set (ASCII characters). Characters outside the ASCII range of characters are returned unchanged. The _tolower() macro is equivalent to the tolower() function, but executes faster. If the value of the c parameter to the _tolower() macro does not have a corresponding lowercase character, the results of the function are undefined. The toupper() function takes an int value that can be represented as an unsigned char or the value of EOF (defined in the stdio.h header file) as its input. When the input of the toupper() function expresses a lowercase letter, and there exists a corresponding uppercase letter (as defined by character type information in the program locale category LC_CTYPE), the corresponding uppercase letter is returned. All other input val- ues in the domain are returned unchanged. The toupper() function has as its domain the range -1 through 255. In the C locale, or in a locale where case-conversion information is not defined, the toupper() function determines the case of characters according to the rules of the Portable Character Set (ASCII characters). Characters outside the ASCII range of characters are returned unchanged. The _toupper() macro is equivalent to the toupper() function, but executes faster. If the value of the c parameter to the _toupper() macro does not have a corresponding uppercase character, the results of the function are undefined. NOTES
The LC_CTYPE category of the current locale affects all conversions. See the i18n_intro(5) reference page for more information on locale variables. RETURN VALUES
The toascii() function returns the logical AND of parameter c and the value 0X7F. When the c parameter is a character for which the isupper() function is TRUE, there is a corresponding character for which the islower() function is also TRUE. That lowercase character is returned by the tolower() function or by the _tolower() macro. Otherwise, the c parame- ter is returned unchanged. When the c parameter is a character for which the islower() function is TRUE, there is a corresponding character for which the isupper() function is also TRUE. That uppercase character is returned by the toupper() function or by the _toupper() macro. Otherwise, the c parame- ter is returned unchanged. RELATED INFORMATION
Functions: ctype(3) Other: i18n_intro(5), standards(5) delim off conv(3)
All times are GMT -4. The time now is 11:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy