Sponsored Content
Top Forums Shell Programming and Scripting shell script to remove all lines from a file before a line starting with pattern Post 302301907 by Franklin52 on Sunday 29th of March 2009 07:04:14 AM
Old 03-29-2009
Code:
sed -n '/.1.2/,$p' file

or:

Code:
awk '/.1.2/{p=1}p' file

Regards
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

shell script to replace a line contain an unkown pattern starting with "aaa, bbb"

Hello, can any one help me on this? I have a /etc/exports file, it may contain a line (I can not remember exactly). Let me use an a sample file myfile.txt which contains a line * mypattern uncertain key words I want this line (with any possible combination of the uncertain key words to be... (2 Replies)
Discussion started by: Dingrong
2 Replies

2. Shell Programming and Scripting

Shell script to remove duplicates lines in a file

Hi, I am writing a shell script that needs to remove duplicate lines within a file by category. example: section a a c b a section b a b a c I need to remove the duplicates within th category with out removing the duplicates from the 2 different sections (one of the a's in section... (1 Reply)
Discussion started by: RichElks
1 Replies

3. Shell Programming and Scripting

How to remove particular line from file through shell script?

Hi, I am pasring a file line by line. I need to check each field in line and remove particular line. input file lines are, 02;ABC;PQR 03;aaa;rrr 04;ABC;ggg 09;eee;ABC 04;lmn;stu I am looking for line containing "ABC" as field value. Now How can I remove this line from input file... (7 Replies)
Discussion started by: Poonamol
7 Replies

4. Shell Programming and Scripting

Remove line breaks in csv file using shell script

Hi All, I've a csv file in which the record is getting break into 1 line or more than one line. I want to combine those splits into one line and remove the unwanted character existing in the record i.e. double quote symbol ("). The line gets break only when the record contains double... (4 Replies)
Discussion started by: rajak.net
4 Replies

5. Shell Programming and Scripting

Remove Space and blank line from file in UNIX shell script

I have below file. I want to remove space at begining of every line and then after also remove blank line from file. I use below code for each operation. sed -e 's/^*//' < check.txt > check1.txt sed '/^\s*$/d' < check1.txt > check2.txt above code not remove all the space... (12 Replies)
Discussion started by: Mohin Jain
12 Replies

6. Shell Programming and Scripting

Remove duplicate line starting with a pattern

HI, I have the below input file /* ----------------- cmdsDlyStartFWJ -----------------*/ UNIX_JOB CMDS065J RUN ANY CMDNAME sleep 5 AGENT CMDSHP USER proddata RUN MON,TUE,WED,THU,FRI DELAYSUB 02:00 /* "Triggers daily file watcher jobs" */ ENVAR... (5 Replies)
Discussion started by: varun22486
5 Replies

7. UNIX for Dummies Questions & Answers

Grep -v lines starting with pattern 1 and not matching pattern 2

Hi all! Thanks for taking the time to view this! I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern. Example: Drink a soda Eat a banana Eat multiple bananas Drink an apple juice Eat an apple Eat multiple apples I... (8 Replies)
Discussion started by: demmel
8 Replies

8. UNIX for Dummies Questions & Answers

How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

e.g. File name: File.txt cat File.txt Result: #INBOUND_QUEUE=FAQ1 INBOUND_QUEUE=FAQ2 I want to get the value for one which is not commented out. Thanks, (3 Replies)
Discussion started by: Tanu
3 Replies

9. UNIX for Beginners Questions & Answers

Grep file starting from pattern matching line

I have a file with a list of references towards the end and want to apply a grep for some string. text .... @unnumbered References @sp 1 @paragraphindent 0 2017. @strong{Chalenski, D.A.}; Wang, K.; Tatanova, Maria; Lopez, Jorge L.; Hatchell, P.; Dutta, P.; @strong{Small airgun... (1 Reply)
Discussion started by: kristinu
1 Replies

10. UNIX for Beginners Questions & Answers

awk with sed to combine lines and remove specific odd # pattern from line

In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line... (4 Replies)
Discussion started by: cmccabe
4 Replies
FILTERDIFF(1)							     Man pages							     FILTERDIFF(1)

NAME
filterdiff - extract or exclude diffs from a diff file SYNOPSIS
filterdiff [[-i PATTERN] | [--include=PATTERN]] [[-I FILE] | [--include-from-file=FILE]] [[-p n] | [--strip-match=n]] [--strip=n] [--addprefix=PREFIX] [--addoldprefix=PREFIX] [--addnewprefix=PREFIX] [[-x PATTERN] | [--exclude=PATTERN]] [[-X FILE] | [--exclude-from-file=FILE]] [[-v] | [--verbose]] [--clean] [[-z] | [--decompress]] [[-# RANGE] | [--hunks=RANGE]] [--lines=RANGE] [--files=RANGE] [--annotate] [--format=FORMAT] [--as-numbered-lines=WHEN] [--remove-timestamps] [file...] filterdiff {[--help] | [--version] | [--list] | [--grep ...]} DESCRIPTION
You can use filterdiff to obtain a patch that applies to files matching the shell wildcard PATTERN from a larger collection of patches. For example, to see the patches in patch-2.4.3.gz that apply to all files called lp.c: filterdiff -z -i '*/lp.c' patch-2.4.3.gz If neither -i nor -x options are given, -i '*' is assumed. This way filterdiff can be used to clean up an existing diff file, removing redundant lines from the beginning (eg. the text from the mail body) or between the chunks (eg. in CVS diffs). To extract pure patch data, use a command like this: filterdiff message-with-diff-in-the-body > patch Note that the interpretation of the shell wildcard pattern does not count slash characters or periods as special (in other words, no flags are given to fnmatch). This is so that "*/basename"-type patterns can be given without limiting the number of pathname components. You can use both unified and context format diffs with this program. OPTIONS
-i PATTERN, --include=PATTERN Include only files matching PATTERN. All other lines in the input are suppressed. -I FILE, --include-from-file=FILE Include only files matching any pattern listed in FILE, one pattern per line. All other lines in the input are suppressed. -x PATTERN, --exclude=PATTERN Exclude files matching PATTERN. All other lines in the input are displayed. -X FILE, --exclude-from-file=FILE Exclude files matching any pattern listed in FILE, one pattern per line. All other lines in the input are displayed. -p n, --strip-match=n When matching, ignore the first n components of the pathname. -# RANGE, --hunks=RANGE Only include hunks within the specified RANGE. Hunks are numbered from 1, and the range is a comma-separated list of numbers or "first-last" spans; either the first or the last in the span may be omitted to indicate no limit in that direction. --lines=RANGE Only include hunks that contain lines from the original file that lie within the specified RANGE. Lines are numbered from 1, and the range is a comma-separated list of numbers or "first-last" spans; either the first or the last in the span may be omitted to indicate no limit in that direction. --files=RANGE Only include files indicated by the specified RANGE. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma-separated list of numbers or "first-last" spans; either the first or the last in the span may be omitted to indicate no limit in that direction. --annotate Annotate each hunk with the filename and hunk number. --format=unified|context Use specified output format. --strip=n Remove the first n components of pathnames in the output. --addprefix=PREFIX Prefix pathnames in the output by PREFIX. This will override any individual settings specified with the --addoldprefix or --addnewprefix options. --addoldprefix=PREFIX Prefix pathnames for old or original files in the output by PREFIX. --addnewprefix=PREFIX Prefix pathnames for updated or new files in the output by PREFIX. --as-numbered-lines=before|after Instead of a patch fragment, display the lines of the selected hunks with the line number of the file before (or after) the patch is applied, followed by a TAB character and a colon, at the beginning of each line. Each hunk except the first will have a line consisting of "..." before it. --remove-timestamps Do not include file timestamps in the output. -v, --verbose Always show non-diff lines in the output. By default, non-diff lines are only shown when excluding a filename pattern. --clean Always remove all non-diff lines from the output. Even when excluding a filename pattern. -z, --decompress Decompress files with extensions .gz and .bz2. --help Display a short usage message. --version Display the version number of filterdiff. --list Behave like lsdiff(1) instead. --grep Behave like grepdiff(1) instead. EXAMPLES
To see all patch hunks that affect the first five lines of a C file: filterdiff -i '*.c' --lines=-5 < patch To see the first hunk of each file patch, use: filterdiff -#1 patchfile To see patches modifying a ChangeLog file in a subdirectory, use: filterdiff -p1 Changelog To see the complete patches for each patch that modifies line 1 of the original file, use: filterdiff --lines=1 patchfile | lsdiff | xargs -rn1 filterdiff patchfile -i To see all but the first hunk of a particular patch, you might use: filterdiff -p1 -i file.c -#2- foo-patch If you have a very specific list of hunks in a patch that you want to see, list them: filterdiff -#1,2,5-8,10,12,27- To see the lines of the files that would be patched as they will appear after the patch is applied, use: filterdiff --as-numbered-lines=after patch.file You can see the same context before the patch is applied with: filterdiff --as-numbered-lines=before patch.file Filterdiff can also be used to convert between unified and context format diffs: filterdiff -v --format=unified context.diff SEE ALSO
lsdiff(1), grepdiff(1) AUTHOR
Tim Waugh <twaugh@redhat.com> Package maintainer patchutils 23 Jan 2009 FILTERDIFF(1)
All times are GMT -4. The time now is 08:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy