sed Command - Need Additional Assistnce


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed Command - Need Additional Assistnce
# 1  
Old 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
# 2  
Old 03-31-2006
Code:
sed -e 's/[^,"][ ]"/"/g' inputfile

# 3  
Old 03-31-2006
Sed Command- Need Additional Assistance

Thanks for yoru promtp repsonse, i tried but it did not do anything.
# 4  
Old 03-31-2006
Quote:
Originally Posted by guiguy
Thanks for yoru promtp repsonse, i tried but it did not do anything.
ok, thanks for getting back so promptly and so informatively.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

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

2. UNIX for Dummies Questions & Answers

Output of sed command to another sed command

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

3. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

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

4. Shell Programming and Scripting

Help with if else with additional condition

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

5. Shell Programming and Scripting

Display Additional Variable string in awk print command

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

6. Shell Programming and Scripting

Create a file from ls -l command and append additional info to results

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

7. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

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

8. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

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

9. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

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

10. UNIX for Advanced & Expert Users

Help with Additional Password Features

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
Login or Register to Ask a Question