Most unix commands won't change the input file. Normally you'd redirect the output to another (temporary) file and move it back to the original, but since you're on RHEL you should be able to use sed -i to change the input file inplace.
So I decided to show you my crude way of doing this. Not sure if there is a more elegant solution out there, but here is what I came up with:
Code:
#!/bin/sh
# Script to prompt you for original csv name and the new csv name
#
rm test*
echo "Provide the name of the original csv (e.g. DC_ACCESS_2011.csv) Note: CASE MATTERS!!"
read originalcsv
echo "Please provide request name of new csv"
read newcsv
sed '1,8{/"/d}' $originalcsv > test1.csv
sed 's!\"Element.*!Hostname,Interface,Number of Errors,Bandwidth Utilization!' test1.csv > test2.csv
sed '/Auto Range/d' test2.csv > test3.csv
sed '/From/d' test3.csv > test4.csv
sed '/To:/d' test4.csv > test5.csv
sed -e 's/-Fast/,Fast/; s/-Gig/,Gig/; s/-Port/,Port/; s/-Ten/,Ten/; s/"/ /g' test5.csv > test6.csv
sed '/^$/d' test6.csv > $newcsv
rm test*
exit 0
The original csv is as follows:
Code:
"eDir Top N Report","logoRpt"
"All LAN Interface for DC_ACCESS"
"Shown: Errors above 1.0 K or BW Util above 70.0"
"","Errors","BW Util"
""," ","%"
"","Above","Above"
"","",""
"Element","1.0 K","70.0"
"ios6-qad-rowa2-TenGigabitEthernet6/4",887644.00000000,0.42693967
"ios6-wbd-rowmbaa3-GigabitEthernet2/42",19422.00000000,0.00515052
"ios6-wbd-rowmbaa4-GigabitEthernet2/42",18655.00000000,0.00273238
"Auto Range: Previous 4 Weeks","Subject: DC_ACCESS","Created: 11/28/2011 17:50:45"
"From: 10/31/2011 00:00","","Time Zone: (GMT-08:00) Pacific Time"
"To: 11/27/2011 23:59"
And what I end up with:
Code:
Hostname,Interface,Number of Errors,Bandwidth Utilization
ios6-qad-rowa2,TenGigabitEthernet6/4 ,887644.00000000,0.42693967
ios6-wbd-rowmbaa3,GigabitEthernet2/42 ,19422.00000000,0.00515052
ios6-wbd-rowmbaa4,GigabitEthernet2/42 ,18655.00000000,0.00273238
Again, fairly crude, but I guess it gets the job done.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT DEBIAN
nwbpset
NWBPSET(1) nwbpset NWBPSET(1)NAME
nwbpset - Create a bindery property or set its value
SYNOPSIS
nwbpset [ -h ] [ -S server ] [ -U user name ] [ -P password | -n ] [ -C ]
DESCRIPTION
nwbpset Reads a property specification from the standard input and creates and sets the corresponding property. The format is determined by
the output of 'nwbpvalues -c'. nwbpset will hopefully become an important part of the bindery management suite of ncpfs, together with
'nwbpvalues -c'. See util/nwbpsecurity for an example.
As another example, look at the following command line:
nwbpvalues -t 1 -o supervisor -p user_defaults -c |
sed '2s/.*/ME/'|
sed '3s/.*/LOGIN_CONTROL/'|
nwbpset
With this command, the property user_defaults of the user object 'supervisor' is copied into the property login_control of the user object
'me'.
nwbpvalues -t 1 -o me -p login_control -c |
sed '9s/.*/ff/'|
nwbpset
This command disables the user object me.
Feel free to contribute other examples!
nwbpset looks up the file $HOME/.nwclient to find a file server, a user name and possibly a password. See nwclient(5) for more information.
Please note that the access permissions of $HOME/.nwclient MUST be 600 for security reasons.
OPTIONS -h
-h is used to print out a short help text.
-S server
server is the name of the server you want to use.
-U user
user is the user name to use for login.
-P password
password is the password to use for login. If neither -n nor -P are given, and the user has no open connection to the server, nwbpset
prompts for a password.
-n
-n should be given if no password is required for the login.
-C
By default, passwords are converted to uppercase before they are sent to the server, because most servers require this. You can turn off
this conversion by -C.
AUTHORS
nwbpset was written by Volker Lendecke. See the Changes file of ncpfs for other contributors.
nwbpset 8/7/1996 NWBPSET(1)