sed remove everything between two string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed remove everything between two string
# 1  
Old 06-19-2013
sed remove everything between two string

Hi all,

I have this input:
Code:
"203324780",,"89321213261247090146","VfdsD150","0D","fd3221","V0343","aaa","Direkt","fsa","2015.02.27","39833,54454,21214",,,"fd","NORMAL","D","10fd","1243 Flotta","HiĂĄnytalan","2013.02.25",,"2013.02.25","2013.02.24","2013.02.28",,"SajĂĄt bolt","0","Active","-732",,"f1010","fdsa","PRIV","F,L,EET","FLEET","no","alma","1.0","0.5","0.0","0.0","1.5",,,,,"323232","not","1"

and i would like to remove all character between "".

I would like to get the number of the comma, but you can see some record include comma. So i need to remove everything without comma.

I try to use sed like this:
Code:
sed 's/"[^"]*)//g'

but not work.

Anyone can help me.

Thanks!

Last edited by Franklin52; 06-19-2013 at 06:53 AM.. Reason: Please use code tags
# 2  
Old 06-19-2013
Can you please try :
Code:
awk -F"," ' { print NF-1 } ' file

# 3  
Old 06-19-2013
Code:
$ echo $strg | perl -nle '$tmp=$_;$tmp=~s/\"[^,]*?\"//g;$tmp=~s/\"//g;print $tmp'
,,,,,,,,,,,39833,54454,21214,,,,,,,,,,,,,,,,,,,,,,,F,L,EET,,,,,,,,,,,,, ,,

# 4  
Old 06-19-2013
You almost had it:
Code:
sed 's/"[^"]*"//g'

This User Gave Thanks to Subbeh For This Post:
# 5  
Old 06-19-2013
thanks a lot!

i use this:

Code:
sed 's/"[^"]*"//g' file | perl -nle 'print length'


Last edited by Franklin52; 06-19-2013 at 08:18 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed awk to remove the , in a string

Dear All, Can anyone help to remove the , bewteen "" in a string by using sed or awk? e.g. input : 1,4,5,"abcdef","we,are,here",4,"help hep" output:1,4,5,"abcdef","wearehere",4,"help hep" Thanks, Mimi (5 Replies)
Discussion started by: mimilaw
5 Replies

2. Shell Programming and Scripting

sed command to remove a word from string

Hello All, I am running a command find . -name amp.cfg | cut -c 3- which gives me output something like below rel/prod/amp.cfg rel/fld/amp.cfg deb/detail/amp.cfg deb/err/amp.cfg I want to remove trailing "/amp.cfg" so that i should get output something like... (7 Replies)
Discussion started by: anand.shah
7 Replies

3. Shell Programming and Scripting

Remove duplicate chars and sort string [SED]

Hi, INPUT: DCBADD OUTPUT: ABCD The SED script should alphabetically sort the chars in the string and remove the duplicate chars. (5 Replies)
Discussion started by: jds93
5 Replies

4. Shell Programming and Scripting

remove newline between two string with sed command in unix shellscript

I have a file (test.dat) which contains data like this 459|199811047|a |b |shan kar|ooty| 460|199811047|a |bv |gur u|cbe| but I need it like: 459|199811047|a |b |shankar|ooty| 460|199811047|a |b |guru|cbe| While reading the data from this file, I don't want to remove newline from the end of... (4 Replies)
Discussion started by: jcrshankar
4 Replies

5. Shell Programming and Scripting

Sed is doing my head in! How do you remove the first character of a string?

Hello! Please bare with me, I'm a total newbie to scripting. Here's the sudo code of what I'm trying to do: Get file name Does file exist? If true get length of file name get network id (this will be the last 3 numbers of the file name) loop x 2 If... (1 Reply)
Discussion started by: KatieV
1 Replies

6. Shell Programming and Scripting

use sed to remove year from string?

Hi guys, I have been trying to play with sed to accomplish this but I just can't quite get it right. I need to be able to remove the year from a string held in a variable in my bash script. The string may have multiple words but always ends with a year such as (2009) for example: ... (2 Replies)
Discussion started by: tret
2 Replies

7. Shell Programming and Scripting

sed - remove spaces before 1rst occurence of string

seems easy but havent found in other posts... i want to delete any spaces if found before first occurence of ${AI_RUN} sed 's/ *\\$\\{AI_RUN\\}/\\$\\{AI_RUN\\}/' $HOME/temp1.dat i think i'm close but can't put my finger on it. :rolleyes: (6 Replies)
Discussion started by: danmauer
6 Replies

8. Shell Programming and Scripting

A problem for sed? Remove parts of a string

Hi, My knowledge about sed is limited but I have a problem that I think can be solved with sed. I have a variable in a shell script that stores a lot of path/filenames and the delimitter between them is a space (they all exist on the same line). One part of the filename is the file creation... (4 Replies)
Discussion started by: pcrs
4 Replies

9. Shell Programming and Scripting

How to remove all matches in a string with sed

if I have "abxcdxefx" and want to remove the x's with sed, how can I do this? Thanks. WHOOPS: Just remembered: echo "abxcdxefx" | sed s/x//g Thanks for reading, though. (0 Replies)
Discussion started by: lumix
0 Replies

10. Shell Programming and Scripting

how to remove spaces in a string using sed.

Hello, I have the following to remove spaces from beginning and end of a string. infile=`echo "$infilename" | sed 's/^ *//;s/ *$//` How do I modify the above code to remove spaces from beginning, end and in the middle of the string also. ex: ... (4 Replies)
Discussion started by: radhika
4 Replies
Login or Register to Ask a Question