Sponsored Content
Full Discussion: Grouping sed commands
Top Forums Shell Programming and Scripting Grouping sed commands Post 302607856 by lneedh1 on Thursday 15th of March 2012 01:29:03 PM
Old 03-15-2012
Grouping sed commands

Hello, would you please help me with why my SED command file is outputting the entire input file instead of only the text that I'm trying to block?

Code:
 
cat testfile
O 111111111-00
DUE-DATE
METHOD:
FREQUENCY:
O 222222222-00
DUE-DATE
METHOD:
FREQUENCY:
O 333333333-02
DUE-DATE
METHOD:
FREQUENCY:
 
cat cmdfile
/222222222-00/,/FREQUENCY/ {
s/^/222222222-00 /
}

The entire testfile is displayed with my updates when I run "sed -f cmdfile testfile"

Code:
sed -f cmdfile testfile 
 
O 111111111-00
DUE-DATE
METHOD:
FREQUENCY:
222222222-00 O 222222222-00
222222222-00 DUE-DATE
222222222-00 METHOD:
222222222-00 FREQUENCY:
O 333333333-02
DUE-DATE
METHOD:
FREQUENCY:

Why is it that the cmdfile will update the block of text and output all of the lines?

I would expect that only the block of text I'm grabbing would display with the updates.

I'm trying get the following to be my results
Code:
sed -f cmdfile testfile 
 
222222222-00 O 222222222-00
222222222-00 DUE-DATE
222222222-00 METHOD:
222222222-00 FREQUENCY:

Thank you,
Lon
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed commands

I have a configuration file that when a certain script runs in updates. I want to use sed and can't seem to get the syntax right. A line from the configuration file looks like: DATE=20040909 12:00:10 When the script is run I want to change the date and time, i.e. removing the previous... (7 Replies)
Discussion started by: dbrundrett
7 Replies

2. Shell Programming and Scripting

multiple sed commands

hello! I have a few sed commands sed '/^$/d' < $1 > tmp.t sed '/^ \{3,\}/d' < tmp.t > tmp1.txt ..... how can I write them in a single line? sed '/^$/d' < $1 > | '/^ \{3,\}/d' < $1 > tmp1.txt any idea? thanks. (5 Replies)
Discussion started by: george_
5 Replies

3. UNIX for Dummies Questions & Answers

combining sed commands

I would like to change the lines: originalline1 originalline2 to: originalline1new originalline1newline originalline2new originalline2newline To do this, id like to combine the commands: sed 's/^/&new/g' file > newfile1 and sed '/^/ a\\ newline\\ \\ (2 Replies)
Discussion started by: Dave724001
2 Replies

4. Shell Programming and Scripting

Using variables in sed commands

Hi there, I need to be able to put the hostid of my box into a file (replacing the text "enter_hostid_here" so i tried sed -e 's/enter_hostid_here/`hostid`/g' inputfile > outputfile but it takes the `hostid` literally as text .....how can I get this info into the file (ideally in a single... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

5. Shell Programming and Scripting

gnu sed regex grouping not working?

Hello, from the gnu sed manual, I should be able to do this: `\(REGEXP\)' Groups the inner REGEXP as a whole, this is used to: * Apply postfix operators, like `\(abcd\)*': this will search for zero or more whole sequences of `abcd', while `abcd*' ... (3 Replies)
Discussion started by: Allasso
3 Replies

6. Shell Programming and Scripting

Grouping using sed/awk ?

I run awk cat $1|awk '{print $6}' and get a lot of results and I want results to group them. For example my result is (o/p is unknown to user) xyz xyz abc pqr xyz pqr etc I wanna group them as xyz=total found 7 abc=total .... pqr= Thank (3 Replies)
Discussion started by: pujansrt
3 Replies

7. Shell Programming and Scripting

Running sed commands

Hello I need to run some sed commands but it involves "/" in the substitute or delete, any ideas how I get round the problem. Example: cat file1.txt | sed -e '/</Header>/d' > file2.txt This errors due to the forward slash before the Header text. Thanks (3 Replies)
Discussion started by: Dolph
3 Replies

8. Shell Programming and Scripting

SED:: Using variable while grouping

Hi, I have the following script :- #!/bin/csh -f set var="HOST2" sed -e 's/\(.*TRANSFER TO\).*\(usr\)/\1 "$var" \2/' tempFile tempFile contains: STOP TRANSFER TO HOST1 /usr/bin/myscript 1. How to use variable in the above sed command. It replaces with $var... (6 Replies)
Discussion started by: angshuman_ag
6 Replies

9. Shell Programming and Scripting

merging sed commands

Hi, I've a shell that uses two sed commands to tailor a file. sed 's/ */ /g' | sed 's/%/%%/g' Is it possible to merge this in to a single sed? Thanks! (2 Replies)
Discussion started by: dvah
2 Replies

10. Shell Programming and Scripting

grouping using sed or awk

I have below inside a file. 11.22.33.44 user1 11.22.33.55 user2 I need this manipulated as alias server1.domain.com='ssh user1@11.22.33.44' alias server2.domain.com='ssh user2@11.22.33.55' (3 Replies)
Discussion started by: anil510
3 Replies
CPUPOWER-FREQUENCY-INFO(1)					  cpupower Manual					CPUPOWER-FREQUENCY-INFO(1)

NAME
cpupower frequency-info - Utility to retrieve cpufreq kernel information SYNTAX
cpupower [ -c cpulist ] frequency-info [options] DESCRIPTION
A small tool which prints out cpufreq information helpful to developers and interested users. OPTIONS
-e --debug Prints out debug information. -f --freq Get frequency the CPU currently runs at, according to the cpufreq core. -w --hwfreq Get frequency the CPU currently runs at, by reading it from hardware (only available to root). -l --hwlimits Determine the minimum and maximum CPU frequency allowed. -d --driver Determines the used cpufreq kernel driver. -p --policy Gets the currently used cpufreq policy. -g --governors Determines available cpufreq governors. -a --related-cpus Determines which CPUs run at the same hardware frequency. -a --affected-cpus Determines which CPUs need to have their frequency coordinated by software. -s --stats Shows cpufreq statistics if available. -y --latency Determines the maximum latency on CPU frequency changes. -o --proc Prints out information like provided by the /proc/cpufreq interface in 2.4. and early 2.6. kernels. -m --human human-readable output for the -f, -w, -s and -y parameters. REMARKS By default only values of core zero are displayed. How to display settings of other cores is described in the cpupower(1) manpage in the --cpu option section. You can't specify more than one of the output specific options -o -e -a -g -p -d -l -w -f -y. You also can't specify the -o option combined with the -c option. FILES
/sys/devices/system/cpu/cpu*/cpufreq/ /proc/cpufreq (deprecated) /proc/sys/cpu/ (deprecated) AUTHORS
Dominik Brodowski <linux@brodo.de> - author Mattia Dongili<malattia@gmail.com> - first autolibtoolization SEE ALSO
cpupower-frequency-set(1), cpupower(1) 0.1 CPUPOWER-FREQUENCY-INFO(1)
All times are GMT -4. The time now is 08:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy