03-31-2006
sed Command - Need Additional Assistnce
Here is my data
I have a file in the format below with about 15 fields per each record. I have 2 records displayed below.
"1234","Andy ","Rich ","0001","123 Main Street ","Dallas ", "1"
"2345","Andrew ","Richter ","0002","234 First Ave ","Kirby ", " "
My Final output needs to be as follows
"1234","Andy","Rich","0001","123 Main Street","Dallas","1"
"2345","Andrew","Richter","0002","234 First Ave","Kirby"," "
I am using the following Sed command and it works excep it also deletes the space in the field and I need the last data element to stay like it is either a "1" or a " " (space).
sed -e 's/[ ]"/"/g' inputfile>outputfile...
what do I need to change in the sed command that I am using to get the result that I am looking for. The above is just the sample of the data, and it is not all data elements, there are quite a few additional fields but the last field is what I have in my data sample.
Thanks
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hello:
I have a customer who is requesting the following security features on a Solaris 8 system:
1. Password history for the three previous passwords.
2. User account lockout after 3 failed login attempts.
Can anyone help provide me with a solution or direction for the above? (1 Reply)
Discussion started by: rambo15
1 Replies
2. Shell Programming and Scripting
Sorry for the duplicate thread this one is similar to the one in
https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121
Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies
3. Shell Programming and Scripting
Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line.
... (1 Reply)
Discussion started by: cbo0485
1 Replies
4. UNIX for Dummies Questions & Answers
I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename?
#!/bin/bash
filename=`echo $0`
/usr/bin/sed '/#include/ {
i\
the filename is `$filename`
}' $1
exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies
5. Shell Programming and Scripting
I need to be able to take the results from ls -l command and modify the output as follows:
I will run
ls -l *.mak
My results will be
aa.mak
bb.mak
cc.mak
I then need to take those results and create a file that has the following info:
dsjj/ubin/aa
dsjj/ubin/bb
dsjj/ubin/cc
... (3 Replies)
Discussion started by: jclanc8
3 Replies
6. Shell Programming and Scripting
Hi all,
I have script to monitor and sum up the total memory use up for each individual process.
proc=$1
svmon -P -O summary=basic,unit=MB|awk 'NR>4'|grep -w "${proc}" |awk '{sum+=$3} END {printf "\t" sum """\n";}'
But I would like the script to be able to display as following
... (3 Replies)
Discussion started by: ckwan
3 Replies
7. Shell Programming and Scripting
Input file:
3420023_3422482,3422486_3423070 46910
1795263_1798343 32681
1837399_1838886 1534
2148674_2149696,2149698_2149772 10203
3825382_3825555,3827296_3827900 198
1839890_1840294 72
.
.
Output file
3420023_3422482,3422486_3423070 3420023_3422482,3422486_3423070 46910
1795263... (1 Reply)
Discussion started by: perl_beginner
1 Replies
8. Shell Programming and Scripting
Hi,
I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :-
./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies
9. UNIX for Dummies Questions & Answers
Hi All,
I'm relatively new to Unix scripting and am trying to get my head around piping.
I'm trying to take a header record from one file and prepend it to another file. I've done this by creating several temp files but i'm wondering if there is a cleaner way to do this.
I'm thinking... (10 Replies)
Discussion started by: BigCroyd
10 Replies
10. Shell Programming and Scripting
Hello i am having an issue with bash script and this is the code
now=$(cat hosts1.txt | awk '{print $2;}')
while read n ;do
ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers'
When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies
LEARN ABOUT SUSE
template::plugin::datafile
Template::Plugin::Datafile(3) User Contributed Perl Documentation Template::Plugin::Datafile(3)
NAME
Template::Plugin::Datafile - Plugin to construct records from a simple data file
SYNOPSIS
[% USE mydata = datafile('/path/to/datafile') %]
[% USE mydata = datafile('/path/to/datafile', delim = '|') %]
[% FOREACH record = mydata %]
[% record.this %] [% record.that %]
[% END %]
DESCRIPTION
This plugin provides a simple facility to construct a list of hash references, each of which represents a data record of known structure,
from a data file.
[% USE datafile(filename) %]
A absolute filename must be specified (for this initial implementation at least - in a future version it might also use the
"INCLUDE_PATH"). An optional "delim" parameter may also be provided to specify an alternate delimiter character.
[% USE userlist = datafile('/path/to/file/users') %]
[% USE things = datafile('items', delim = '|') %]
The format of the file is intentionally simple. The first line defines the field names, delimited by colons with optional surrounding
whitespace. Subsequent lines then defines records containing data items, also delimited by colons. e.g.
id : name : email : tel
abw : Andy Wardley : abw@tt2.org : 555-1234
sam : Simon Matthews : sam@tt2.org : 555-9876
Each line is read, split into composite fields, and then used to initialise a hash array containing the field names as relevant keys. The
plugin returns a blessed list reference containing the hash references in the order as defined in the file.
[% FOREACH user = userlist %]
[% user.id %]: [% user.name %]
[% END %]
The first line of the file must contain the field definitions. After the first line, blank lines will be ignored, along with comment line
which start with a '"#"'.
BUGS
Should handle file names relative to "INCLUDE_PATH". Doesn't permit use of '":"' in a field. Some escaping mechanism is required.
AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/>
COPYRIGHT
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Template::Plugin
perl v5.12.1 2008-11-13 Template::Plugin::Datafile(3)