Sponsored Content
Top Forums Shell Programming and Scripting ...yet another string of awk/sed questions from a RegExp-Challenged luser %-\ Post 302358489 by cfajohnson on Friday 2nd of October 2009 05:45:35 PM
Old 10-02-2009
Quote:
Originally Posted by SteveB-in-LV
I'm looking to have sed/awk do some clean-up on routing tables and to that end, I would like to do the following:

1.) If a line contains the word "masks" or "subnets" prepend CR/LF to the beginning of the line.
Code:
awk '/masks/ || /subnet/ { print "" } { print }' "$file"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

regexp with sed again!!!

please help: I want to add 1 space between string and numbers: input file: abcd12345 output file: abcd 1234 The following sed command does not work: sed 's/\(+\)\(+\)/\1 \2/' file Any ideas, please Andy (2 Replies)
Discussion started by: andy2000
2 Replies

2. Shell Programming and Scripting

regexp to get first line of string

Hi everybody for file in * #Bash performs filename expansion #+ on expressions that globbing recognizes. do output="`grep -n "$1" "$file"`" echo "$file: `expr "$output" : '\(^.*$\)'`" done In the above bash script segment, I try to print just the first line of string named... (3 Replies)
Discussion started by: jonas.gabriel
3 Replies

3. Shell Programming and Scripting

sed regexp

Hi, I am not that good with reg exp and sed. But I was just looking at something the other day and came across a situation. When I ran the below command: echo "123 word" | sed 's/*/(&)/' the op was: (123) word But when I ran: echo "123 word" | sed 's/*/(&)/g' the o/p was: (123)... (4 Replies)
Discussion started by: King Nothing
4 Replies

4. UNIX for Dummies Questions & Answers

sed before and after regexp

Dear all i have the code which print 1 line of context before and after regexp, with line number sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h the code work well but any one can tell me what each letter mean {=;x;1!p;g;$!N;p;D;} also how i can print 2 line before and onle line after ... (2 Replies)
Discussion started by: soly
2 Replies

5. Shell Programming and Scripting

awk, sed or perl regexp to print values from file

Hello all According to the following file (orignal one contains 200x times the same structure...) I was wondering if someone could help me to print <byte>??</byte> values example, running this script/command like ./script.sh xxapp I would expect as output: 102 116 112 ./script.sh xxapp2... (2 Replies)
Discussion started by: cabrao
2 Replies

6. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

7. Shell Programming and Scripting

Couple of easy questions for experts on awk/sed

Hello Experts.. I have 3-4 C codes with Oracle SQL statements embedded. All the SQL statements starts with EXEC SQL keyword and ends with ;. I want to extract all the SQL statements out of these codes. I did awk '/^EXEC SQL/,/\;/' inputFile (I use this on all of the codes individually). That... (2 Replies)
Discussion started by: juzz4fun
2 Replies

8. Shell Programming and Scripting

Regexp for string that might contain a given character

I'm probably just not thinking of the correct term to search for :-) But I want to match a pattern that might be 'ABC' or '1ABC' there might be three characters, or there might be four, but if there are four, the first has to be 1 (1 Reply)
Discussion started by: jnojr
1 Replies

9. Shell Programming and Scripting

Replace string in XML file with awk/sed with string from another

Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file: </member> <member> <name>TransactionID</name> <value><string>123456789123456</string></value> </member> <member> <name>Number</name> ... (9 Replies)
Discussion started by: cozzin
9 Replies

10. UNIX for Beginners Questions & Answers

awk or sed to print the character from the previous line after the regexp match

Hi All, I need to print the characters in the previous line just before the regular expression match Please have a look at the input file as attached I need to match the regular expression ^ with the character of the previous like and also the pin numbers and the output file should be like... (6 Replies)
Discussion started by: kshitij
6 Replies
BIND::Config::Parser(3pm)				User Contributed Perl Documentation				 BIND::Config::Parser(3pm)

NAME
BIND::Config::Parser - Parse BIND Config file. SYNOPSIS
use BIND::Config::Parser; # Create the parser my $parser = new BIND::Config::Parser; my $indent = 0; # Set up callback handlers $parser->set_open_block_handler( sub { print " " x $indent, join( " ", @_ ), " { "; $indent++; } ); $parser->set_close_block_handler( sub { $indent--; print " " x $indent, "}; "; } ); $parser->set_statement_handler( sub { print " " x $indent, join( " ", @_ ), "; "; } ); # Parse the file $parser->parse_file( "named.conf" ); DESCRIPTION
BIND::Config::Parser provides a lightweight parser to the configuration file syntax of BIND v8 and v9 using a "Parse::RecDescent" grammar. It is in a similar vein to "BIND::Conf_Parser". However, as it has no knowledge of the directives, it doesn't need to be kept updated as new directives are added, it simply knows how to carve up a BIND configuration file into logical chunks. CONSTRUCTOR
new( ); Create a new "BIND::Config::Parser" object. METHODS
set_open_block_handler( CODE_REF ); Set the code to be called when a configuration block is opened. At least one argument will be passed; the name of that block, for example "options" or "zone", etc. as well as any additional items up to but not including the opening curly brace. set_close_block_handler( CODE_REF ); Set the code to be called when a configuration block is closed. No arguments are passed. set_statement_handler( CODE_REF ); Set the code to be called on a single line configuration element. At least one argument will be passed; the name of that element, as well as any additional items up to but not including the ending semi-colon. parse_file( FILENAME ); Parse FILENAME, triggering the above defined handlers on the relevant sections. TODO
Probably the odd one or two things. I'm fairly sure the grammar is correct. COPYRIGHT AND LICENSE
Copyright (c) 2005 Matt Dainty. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHORS
Matt Dainty <matt@bodgit-n-scarper.com>. SEE ALSO
perl, Parse::RecDescent, BIND::Conf_Parser. perl v5.14.2 2005-06-26 BIND::Config::Parser(3pm)
All times are GMT -4. The time now is 01:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy