06-10-2009
Quote:
sed -n '/select/I,/;/{/;/G;p}
' infile
Awsome!...... in my quest to understand the hows and whys of SED, ( so as not to just be a coding monkey
) could you explaing the part in red
sed -n '/select/I,/;/
{/;/G;p}
i beleive the p is to output the results and /;/G to add a blank line..
but I don't understand the purpose/usage of the construct
{ .... } and the
; between G & p
Can you help me understand so i can use this in the future?
PS: could you recommend a usefull sed book?
Thanks in advance for you help
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I followed the egrep example given in the thread "parse text or complex grep ?". It is exactly what I need...except... how do I insert a blank line after the second line? My exact command is:
egrep 'patt1|patt2' filename
the result is:
patt1
patt2
patt1
patt2
and so on. I would... (2 Replies)
Discussion started by: antalexi
2 Replies
2. Shell Programming and Scripting
Hello friends,
I have a C source code containing sql statements. I use the following sed command to print all the sql blocks in the source code....
sed -n "/exec sql/,/;/p" Sample.cpp
The above sed command will print the sql blocks based on the pattern "exec sql" & ";"... (2 Replies)
Discussion started by: frozensmilz
2 Replies
3. Shell Programming and Scripting
FIle A
"A" 2 aa 34
3 ac
5 cd
"B" 3 hu 67
4 fg
5 gy
output shud be
A"" 2 aa 34
"A" 3 ac 34
"A" 5 cd 34
"B" 3 hu 67
"B" 4 fg 67
"B" 5 gy 67 (6 Replies)
Discussion started by: cdfd123
6 Replies
4. Shell Programming and Scripting
Hi,
I need to match lines after a pattern, upto the first blank line.
Searched in web and some forums but coulnt find the answer.
where <restart_step> =
10 -- Execute query
20 -- Write the contents to the Oracle table
30 -- Writing Contents to OUTPUT... (7 Replies)
Discussion started by: justchill
7 Replies
5. Shell Programming and Scripting
Hello...
I have a file which contain certain number of records.
I want to generate another file from this file which will contain 1st line as a blank line & after every 5 lines one blank line will be inserted. How to achieve this through shell scripting?
Thanks... (5 Replies)
Discussion started by: 46019
5 Replies
6. Shell Programming and Scripting
I use the following as part of a script to correct for a faulty hostname file.
# get the domain name
read -r thehostname < /etc/hostname
dom="$(echo $thehostname | cut -d'.' -f2)"
numchar=${#dom}
if
then
echo "It appears as though the hostname is not correctly set."
echo "Hostname has... (5 Replies)
Discussion started by: bugeye
5 Replies
7. Shell Programming and Scripting
Hi
Im trying to do the following in sed. I want to delete any blank line at the start of a file until it matches a pattern and then stops. for example:
Input
output:
I have got it to work within a range of two patterns with the following:
sed '/1/,/pattern/{/^]*$/d}'
The... (2 Replies)
Discussion started by: duonut
2 Replies
8. Shell Programming and Scripting
cat test.txt
a
c
d
e
g (2 Replies)
Discussion started by: TomG
2 Replies
9. Shell Programming and Scripting
Hi Guys,
I am stuck in between and seeking help here.
Requirement: A script that will run every morning which will connect to Mysql database and run the query to inform us about the holidays (it will also check if there were any holidays during last 2 business days). So the three queries are... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies
10. Shell Programming and Scripting
Input: START
OS:: UNIX
Release: xxx
Version: xxx
END
START
OS:: LINUX
Release: xxx
Version: xxx
END
START
OS:: Windows
Release: xxx
Version: xxx
ENDHere i am trying to get all the information between START and END, only if i could match OS Type.
I can get all the data between the... (3 Replies)
Discussion started by: Dharmaraja
3 Replies
LEARN ABOUT DEBIAN
mencal
mencal(1) 1 mencal(1)
NAME
mencal - menstruation calendar
SYNOPSIS
mencal [options] [file1 file2 ... -c CONF1 -c CONF2 ...]
DESCRIPTION
Display options:
-m, --monday
draw monday as first weekday (sunday is default)
-1 current month (default)
-3 previous, current and next month
-y [YYYY]
all-year calendar (default YYYY is current year)
-q, --quiet
no top information will be printed
-n, --nocolor
noncolored output
-i, --icolor COLOR
intersection color (default red)
available colors: red, green, blue, yellow, violet, cyan, shiny, bold
mencal configuration:
-c, --config
s=[YYYY]MMDD,l=LL,d=DD,n=NAME,f=FILE,c=COLOR
The second argument is a comma separated list of options. No spaces are allowed in this list. If no name is specified, 'Unknown' is
used. Various -c options or filenames can be set.
s,start=[YYYY]MMDD
start day of period (default current day)
l,length=LL
length of period in days (default 28)
d,duration=D
duration of menstruation in days (default 4)
n,name=NAME
name of subject
f,file=FILE
filename to save configuration to (see section FILES)
only menstruation related variables will be saved
c,color=COLOR
color used for menstruation days
available colors: red, green, blue, yellow, violet, cyan, shiny, bold default color is red, with '-n' switch color settings are
ignored
Info options:
-h, --help
print help
-V, --version
print version information
FILES
:
$HOME/.mencalrc - the default configuration file that is automatically loaded
AUTHOR
:
(C) 2002 C. McCohy
e-mail: <mccohy@kyberdigi.cz>
Word-Wide-Web: http://www.kyberdigi.cz/projects/mencal/english
This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page (but may be
used by others).
HISTORY
22 March 2002 - Originally written by Amaya Rodrigo <amaya@debian.org>.
24 Apr 2002 - New manpage contributed by Pablo S. Torralba <psanchez@skyrealms.org>.
Amaya Rodrigo <amaya@debian.org> is now responsible for developing and maintaining this manual page. Comments and suggestions are greatly
wellcome.
mencal Menstruation calendar mencal(1)