Sponsored Content
Top Forums Shell Programming and Scripting using sed/awk to replace a block of text in a file? Post 302577769 by kiddsupreme on Wednesday 30th of November 2011 12:51:36 AM
Old 11-30-2011
I've tried some suggestions with the real case I have, but I haven't had any success. Perhaps if I show you what I am working with it will make more sense. The following is a CSV file that I am working on:

Code:
 eDir Top N Report , logoRpt 
 All LAN Interface for ACCESS 
 Shown: Errors above 1.0 K or BW Util above 70.0 

  , Errors , BW Util 
  ,   , % 
  , Above , Above 
  ,  ,  
 Element , 1.0 K , 70.0 
 cat65-acomp-d,FastEthernet4/18 ,974787.00000000,0.03142596
 ios6-zdc-g2,TenGigabitEthernet6/4 ,887644.00000000,0.42693967
 ios6-dc-a,GigabitEthernet2/12 ,71172.00000000,12.59653282

What I am trying to make it look at is the following:

Code:
 Hostname,Interface,Number of Errors,Bandwidth Utilization
 cat65-acomp-d,FastEthernet4/18 ,974787.00000000,0.03142596
 ios6-zdc-g2,TenGigabitEthernet6/4 ,887644.00000000,0.42693967
 ios6-dc-a,GigabitEthernet2/12 ,71172.00000000,12.59653282

The bold parts are the items that are actually changing. So in this case, the report I run will always start with "eDir" and end with "70.0" (The second occurrence for those eagle eyed). I want that replaced with what is in the second example. Any chance on getting that to work? Thank you again for all your help, I do appreciate it.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace a range of text with sed or awk?

Howdy! I'm trying to automate editing of a configuration file (custom.conf for GDM). I need to find every line between a line that starts with "" and the next line that starts with "", I want to preserve that line, but then delete all the lines in that configuration section and then insert... (3 Replies)
Discussion started by: TXTad
3 Replies

2. Shell Programming and Scripting

pattern replace inside text file using sed

Hi, I have a situation where I want to replace some occurrences of ".jsp" into ".html" inside a text file. For Example: If a pattern found like <a href="http://www.mysite.com/mypage.jsp"> it should be retained. But if a pattern found like <a href="../mypage.jsp"> it should be changed to... (4 Replies)
Discussion started by: meharo
4 Replies

3. Shell Programming and Scripting

replace block of text with content of another file

Hello, file1: not to be changed not to be changed <start> old stuff old stuff old stuff <end> not to be changed not to be changed file2: new text new text desired output: (3 Replies)
Discussion started by: ripat
3 Replies

4. Shell Programming and Scripting

How to replace multiple text in a file using sed

can anyone please help me in the below scenario: File1: Hello1 Hello1 i want to use sed to replace multiple occurances of Hello1 in file 1 to welcome. Thanks a ton for the help (9 Replies)
Discussion started by: amithkhandakar
9 Replies

5. Shell Programming and Scripting

Delete first block of text with sed/awk

Hello, guys! "filename" has blocks with three lines each in this fashion: 93909286 #verified has one bug 10909286 #unverified pending 10909286 #unverified pendingThe above example has duplicate blocks, and I have tried using sed to remove just one block... The... (2 Replies)
Discussion started by: teresaejunior
2 Replies

6. UNIX for Dummies Questions & Answers

Use sed to replace but only in a specific column of the text file

Hi, I would like to use sed to replace NA to x ('s/NA/x/g'), but only in the 5th column of the space delimited text file, nowhere else. How do I go about doing that? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

7. UNIX for Dummies Questions & Answers

Using sed to replace / in text file

Hi, I want to use sed to replace " /// " with "///" in a text file. However I am getting error messages when I use sed 's/ /// /////g' input.txt > output.txt. How do I go about doing this in sed? Input: 219518_s_at 0.000189 ELL3 / SERINC4 Output: 219518_s_at 0.000189 ELL3/SERINC4 (5 Replies)
Discussion started by: evelibertine
5 Replies

8. Shell Programming and Scripting

Pattern replace from a text file using sed

I have a sample text format as given below <Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text> <Text Text_ID="10155645315851111_10155645317023456" From="1626711840902323"... (3 Replies)
Discussion started by: my_Perl
3 Replies

9. Debian

Using awk and sed to replace text

Good Day Every one I have a problem finding and replacing text in some large files that will take a long time to manually edit. Example text file looks like this #Example Large Text File unix linux dos squid bind dance bike car plane What im trying to do is to edit all the... (4 Replies)
Discussion started by: linuxjunkie
4 Replies

10. UNIX for Beginners Questions & Answers

Help with awk or sed Command to Replace Text in Files

Hello Everyone, I have many files like so: file1.txt file2.txt file3.txt Within each file I have many lines of random text separated by commas like so: abcAAA,123,defAA,456777,ghiA,789 jklB,101,mnoBBB,11211,pqrB,13111 stuCC,415,vwxCCCC,161,yzaC,718 I am trying to use SED or AWK to... (4 Replies)
Discussion started by: D3U5X
4 Replies
IPSEC_KLIPSDEBUG(5)						  [FIXME: manual]					       IPSEC_KLIPSDEBUG(5)

NAME
ipsec_klipsdebug - list KLIPS (kernel IPSEC support) debug features and level SYNOPSIS
ipsec klipsdebug cat/proc/net/ipsec_klipsdebug DESCRIPTION
/proc/net/ipsec_klipsdebug lists flags that control various parts of the debugging output of KLIPS and MAST, two of the IPsec stacks supported by Openswan. At this point it is a read-only file. A table entry consists of: + a KLIPS debug variable + a '=' separator for visual and automated parsing between the variable name and its current value + hexadecimal bitmap of variable's flags. The variable names roughly describe the scope of the debugging variable. Currently, no flags are documented or individually accessible yet except tunnel-xmit. The variable names are: tunnel tunnelling code netlink userspace communication code (obsolete) xform transform selection and manipulation code eroute eroute table manipulation code spi SA table manipulation code radij radij tree manipulation code esp encryptions transforms code ah authentication transforms code rcv receive code ipcomp ip compression transforms code verbose give even more information, beware this will probably trample the 4k kernel printk buffer giving inaccurate output All KLIPS debug output appears as kernel.info messages to syslogd(8). Most systems are set up to log these messages to /var/log/messages. EXAMPLES
debug_tunnel=00000010. debug_netlink=00000000. debug_xform=00000000. debug_eroute=00000000. debug_spi=00000000. debug_radij=00000000. debug_esp=00000000. debug_ah=00000000. debug_rcv=00000000. debug_pfkey=ffffffff. means that one tunnel flag has been set (tunnel-xmit), full pfkey sockets debugging has been set and everything else is not set. FILES
/proc/net/ipsec_klipsdebug, /usr/local/bin/ipsec SEE ALSO
ipsec(8), ipsec_manual(8), ipsec_tncfg(8), ipsec_eroute(8), ipsec_spi(8), ipsec_spigrp(8), ipsec_klipsdebug(5), ipsec_version(5), ipsec_pf_key(5) HISTORY
Written for the Linux FreeS/WAN project <http://www.freeswan.org/> by Richard Guy Briggs. [FIXME: source] 10/06/2010 IPSEC_KLIPSDEBUG(5)
All times are GMT -4. The time now is 05:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy