How to remove space in sed for / character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to remove space in sed for / character
# 1  
Old 06-17-2009
How to remove space in sed for / character

Hi...
i need a script to remove the space before and after the operator like( / ).
Ex :
Input file
apple / manago
mango / fresh apple / fresh

Desired output:
apple/manago
mango/fresh apple/fresh

Note: betwee the desired operator space should be removed, between words do not remove space.
Thanks in advance,
Vasanth

-----Post Update-----

thanks

-----Post Update-----

THanks
# 2  
Old 06-17-2009
https://www.unix.com/shell-programmin...-required.html

Try modifying the solution given to you few mins ago...
# 3  
Old 06-17-2009
Dear rakeshawasthi

i tried but for \ character it is giving error...

kindly guide me to solve this....

vasanth

-----Post Update-----

sorry it is not \ character. the problem is with / charcter.


That is slash character.

-----Post Update-----

sorry it is not \ character. the problem is with / charcter.


That is slash character.
# 4  
Old 06-17-2009
Code:
echo "apple / mango /jack  " | sed -e 's|[ ]*/[ ]*|/|g'


Last edited by panyam; 06-17-2009 at 10:15 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to remove first and last character using sed

Hi I have file in below format. How i can remove the first and lost comma from this below file ,001E:001F,,,02EE,0FED:0FEF, I need output has below 001E:001F,,,02EE,0FED:0FEF (6 Replies)
Discussion started by: ranjancom2000
6 Replies

2. UNIX for Beginners Questions & Answers

Remove space with sed

Hello Folks , myfile contains 1000000 records as follows: logver=56 idseq=63256 itime=1111 devid=TG-40 devname=PUI-C2 vd=USER date=2019_01_10 time=18:39:49 logid="000013" type="traffic" subtype="forward" level="notice" eventtime=134 srcip=1.1.1.1 srcport=1 srcintf="XYX-CORE.01"... (3 Replies)
Discussion started by: arm
3 Replies

3. UNIX for Beginners Questions & Answers

How do I remove leading spaces in UNIX when count of space character is not fixed? Example below-

Script showStreamsGLIS$reg.$env.ksh gives me output as below- Job Stime Etime Status ExitCode GLIS-AS-S-EFL-LOCK-B ----- ----- OI 103313880/0 GLIS-ALL-Q-EOD-FX-UPDT-1730-B ----- ----- TE 0/0 GLIS-TK-S-BWSOD-B ... (8 Replies)
Discussion started by: Tanu
8 Replies

4. Shell Programming and Scripting

Remove blank space and insert special character

Hi Folks, I have a huge data of the below format abc #apple 1200 06/23 ghj #orange 1500 06/27 uyt #banana 2300 05/13 efg #vegetable 0700 04/16 After first 3 letters, i have 9 spaces and after fruit there are no specific fixed space, but it varies... (4 Replies)
Discussion started by: jayadanabalan
4 Replies

5. Shell Programming and Scripting

Remove new line character and add space to convert into fixed width file

I have a file with different record length. The file as to be converted into fixed length by appending spaces at the end of record. The length should be calculated based on the record with maximum length in the file. If the length is less than the max length, the spaces should be appended... (4 Replies)
Discussion started by: Amrutha24
4 Replies

6. UNIX for Dummies Questions & Answers

Adding space after character using sed?

dears i have the data below, i want a command ( i think it should be sed) that add a space after the seconds as below : Jun 24 22:28:18966568406148@ Jun 24 05:47:35966555747744@ Jun 24 05:47:53966560825239@ Jun 24 06:07:52966541147164@ Jun 24 15:49:55966566478883@ thanks... (5 Replies)
Discussion started by: thehero
5 Replies

7. Shell Programming and Scripting

Remove space before a character

Hi guys, I am new to shell scripting and I have a small problem...If someone can solve this..that would be great I am trying to form a XML by reading a flat file using shell scripting This is my shell script LINE_FILE1=`cat FLEX_FILE1.TXT | head -1 | tail -1` echo... (1 Reply)
Discussion started by: gowrishankar05
1 Replies

8. UNIX for Dummies Questions & Answers

sed with variable containing space character

Hi all, I have the following script S1a="13 9 -0.0012041" S1b="13 8 -1.00000 " sed 's/${S1b}/${S1a}/g' funE00.i > tmp1 but the strings are not replaced. Maybe the problem is in the spaces cointaned in the variables? Thanks for your help, Sarah (2 Replies)
Discussion started by: f_o_555
2 Replies

9. Shell Programming and Scripting

sed to remove character ['

I have a huge file where the each column has data in the format: . I want to remove the from each value. How do I do it with sed? thanks (2 Replies)
Discussion started by: manishabh
2 Replies

10. Shell Programming and Scripting

how to delete space character with sed

hi all, i want to delete a space character in word on unix script with command sed like : #dia n result: #dian is there anyone will help me ? regards, cahyo (1 Reply)
Discussion started by: cahyo3074
1 Replies
Login or Register to Ask a Question