Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to replace two or more spaces with one comma? Post 302780589 by Scottie1954 on Thursday 14th of March 2013 06:16:50 PM
Old 03-14-2013
How to replace two or more spaces with one comma?

I'm using sh on hp-ux. I've got a file that looks like this.

Code:
-5.65   175
-16.17  160
-13.57  270
-51.72  260
-8.30   360
-42.71  460
-.38    375
-.20    375
-4.15   170
-21.53  560
-18.84  360

I'd like to replace all the whitespace between the columns with one comma. I can't seem to get the awk, sed, and tr examples I've found to handle the repeating spaces very well.

Thank you!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace , (comma) with space

Hi, what is the better way to replace the , (comma) with a space char? Example:STRING=dir1,dir2,dir3 toSTRING=dir1 dir2 dir3 And.. how to find if in the string there is a comma? Thanks :) (6 Replies)
Discussion started by: mbarberis
6 Replies

2. Shell Programming and Scripting

replace comma(,) with Tab

hi all, i have a file with commas(,). i want to replace all the commas with tab(\t). Plz help...its urgent... (3 Replies)
Discussion started by: vikas_kesarwani
3 Replies

3. Shell Programming and Scripting

Replace comma with newline

Hi, for some reason I cant seem to figure this out. I have a file which looks something like this word word word word word,word,word word word word,word,word,word,word word word Basically I want this whole thing to be a list with 1 word on each line like this... word word word... (1 Reply)
Discussion started by: eltinator
1 Replies

4. Shell Programming and Scripting

How to Use Sed Command to replace white spaces with comma from between two fields - Mayank

SHELL SCRIPT Hi I have a file in the following format Mayank Sushant Dheeraj Kunal ARUN Samir How can i replace the white space in between and replace them with a comma?? The resultant output should be Mayank,Sushant Dheeraj,Kunal ARUN,Samir i tried using sed -e... (8 Replies)
Discussion started by: mayanksargoch
8 Replies

5. Shell Programming and Scripting

Replace the | with Comma

Hi, The input file structure is given below: The Col1 and Col2 will be there always. But from Col3 there can be more columns. And Col3 will be always Col4 and Col5 will always be with Col6. I need to replace the | with comma. There are scnearios where there wont be no data.Below, the row 2... (6 Replies)
Discussion started by: bharathappriyan
6 Replies

6. Shell Programming and Scripting

Replace newline with comma.

I have output from a file like this: 15,01,11,14:06 235 I would like to change this to: 15,01,11,14:06,235 Removing newline and change to "," I now this can be done with tr cat OUT | tr '\n' ','' My problem is that tr is not implemented in this shell. sed is, show it should be... (7 Replies)
Discussion started by: Jotne
7 Replies

7. UNIX for Dummies Questions & Answers

Need help removing leading spaces from one field in comma seperated file

Using awk or sed, I'd like to remove leading spaces after a comma and before a right justified number in field 6. Sounds simple but I can't find a solution. Each field's formatting must stay intact. Input: 40,123456-02,160,05/24/2012,02/13/1977, 10699.15,0 Output:... (5 Replies)
Discussion started by: Scottie1954
5 Replies

8. Shell Programming and Scripting

How to replace NewLine with comma using sed?

Hi , I have a huge file with following records and I want to replace the last comma with ',NULL'. I try using SED but could not create a correct script . In my opinion I need a script which can convert ,/n with ,NULL/n 1,CHANGE_MEMBER,2010-12-28 00:05:00, 2,CHANGE_MEMBER,2012-09-02... (8 Replies)
Discussion started by: Ajaypal
8 Replies

9. Shell Programming and Scripting

Replace comma and blank with comma and number

I, I have a file and i need to replace comma and blank space with comma and 0. cat file.txt a,5 b,1 c, d, e,4 I need the output as cat file.txt a,5 b,1 c,0 d,0 (4 Replies)
Discussion started by: jaituteja
4 Replies

10. Shell Programming and Scripting

Replace spaces with underscores up to first comma but not after the comma

I have a comma delimited file of major codes and descriptions. I want to replace all occurrences of spaces with underscores up to the first comma (only in the first field), but not replace spaces following the comma. For instance I have the following snippet of the file: EK ED,Elementary and... (7 Replies)
Discussion started by: tdouty
7 Replies
iconv_1251(5)						Standards, Environments, and Macros					     iconv_1251(5)

NAME
iconv_1251 - code set conversion tables for MS 1251 (Windows Cyrillic) DESCRIPTION
The following code set conversions are supported: +-------------------------------------------------------------------------+ | Code Set Conversions Supported | +--------------+--------+--------------+--------+-------------------------+ | Code |Symbol |Target Code |Symbol | Target Output | +--------------+--------+--------------+--------+-------------------------+ |MS 1251 |win5 |ISO 8859-5 |iso5 | ISO 8859-5 Cyrillic | +--------------+--------+--------------+--------+-------------------------+ |MS 1251 |win5 |KOI8-R |koi8 | KOI8-R | +--------------+--------+--------------+--------+-------------------------+ |MS 1251 |win5 |PC Cyrillic |alt | Alternative PC Cyrillic | +--------------+--------+--------------+--------+-------------------------+ |MS 1251 |win5 |Mac Cyrillic |mac | Macintosh Cyrillic | +--------------+--------+--------------+--------+-------------------------+ CONVERSIONS
The conversions are performed according to the following tables. All values in the tables are given in octal. MS 1251 to ISO 8859-5 For the conversion of MS 1251 to ISO 8859-5, all characters not in the following table are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | MS 1251 | ISO 8859-5 | MS 1251 | ISO 8859-5 | |24 | 4 |310 |270 | |200 | 242 |311 |271 | |201 | 243 |312 |272 | |202 | 40 |313 |273 | |203 | 363 |314 |274 | |204-207 | 40 |315 |275 | |210 | 255 |316 |276 | |211 | 40 |317 |277 | |212 | 251 |320 |300 | |213 | 40 |321 |301 | |214 | 252 |322 |302 | |215 | 254 |323 |303 | |216 | 253 |324 |304 | |217 | 257 |325 |305 | |220 | 362 |326 |306 | |221-227 | 40 |327 |307 | |230 | 255 |330 |310 | |231 | 40 |331 |311 | |232 | 371 |332 |312 | |233 | 40 |333 |313 | |234 | 372 |334 |314 | |235 | 374 |335 |315 | |236 | 373 |336 |316 | |237 | 377 |337 |317 | |241 | 256 |340 |320 | |242 | 376 |341 |321 | |243 | 250 |342 |322 | |244-247 | 40 |343 |323 | |250 | 241 |344 |324 | |251 | 40 |345 |325 | |252 | 244 |346 |326 | |253-254 | 40 |347 |327 | |255 | 55 |350 |330 | |256 | 40 |351 |331 | |257 | 247 |352 |332 | |260-261 | 40 |353 |333 | |262 | 246 |354 |334 | |263 | 366 |355 |335 | |264-267 | 40 |356 |336 | |270 | 361 |357 |337 | |271 | 360 |360 |340 | |272 | 364 |361 |341 | |273 | 40 |362 |342 | |274 | 370 |363 |343 | |275 | 245 |364 |344 | |276 | 365 |365 |345 | |277 | 367 |366 |346 | |300 | 260 |367 |347 | |301 | 261 |370 |350 | |302 | 262 |371 |351 | |303 | 263 |372 |352 | |304 | 264 |373 |353 | |305 | 265 |374 |354 | |306 | 266 |375 |355 | |307 | 267 |376 |356 | +---------------+----------------+----------------+---------------+ MS 1251 to KOI8-R For the conversion of MS 1251 to KOI8-R , all characters not in the following table are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | MS 1251 | KOI8-R | MS 1251 | KOI8-R | |24 | 4 |310 |351 | |200 | 261 |311 |352 | |201 | 262 |312 |353 | |202 | 40 |313 |354 | |203 | 242 |314 |355 | |204-207 | 40 |315 |356 | |210 | 255 |316 |357 | |211 | 40 |317 |360 | |212 | 271 |320 |362 | |213 | 40 |321 |363 | |214 | 272 |322 |364 | |215 | 274 |323 |365 | |216 | 273 |324 |346 | |217 | 277 |325 |350 | |220 | 241 |326 |343 | |221-227 | 40 |327 |376 | |230 | 255 |330 |373 | |231 | 40 |331 |375 | |232 | 251 |332 |377 | |233 | 40 |333 |371 | |234 | 252 |334 |370 | |235 | 254 |335 |374 | |236 | 253 |336 |340 | |237 | 257 |337 |361 | |241 | 276 |340 |301 | |242 | 256 |341 |302 | |243 | 270 |342 |327 | |244-247 | 40 |343 |307 | |250 | 263 |344 |304 | |251 | 40 |345 |305 | |252 | 264 |346 |326 | |253-254 | 40 |347 |332 | |255 | 55 |350 |311 | |256 | 40 |351 |312 | |257 | 267 |352 |313 | |260-261 | 40 |353 |314 | |262 | 266 |354 |315 | |263 | 246 |355 |316 | |264-267 | 40 |356 |317 | |270 | 243 |357 |320 | |271 | 260 |360 |322 | |272 | 244 |361 |323 | |273 | 40 |362 |324 | |274 | 250 |363 |325 | |275 | 265 |364 |306 | |276 | 245 |365 |310 | |277 | 247 |366 |303 | |300 | 341 |367 |336 | |301 | 342 |370 |333 | |302 | 367 |371 |335 | |303 | 347 |372 |337 | |304 | 344 |373 |331 | |305 | 345 |374 |330 | |306 | 366 |375 |334 | |307 | 372 |376 |300 | +---------------+----------------+----------------+---------------+ MS 1251 to PC Cyrillic For the conversion of MS 1251 to PC Cyrillic, all characters not in the following table are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | MS 1251 | PC Cyrillic | MS 1251 | PC Cyrillic | |24 | 4 |332 |232 | |200-207 | 40 |333 |233 | |210 | 260 |334 |234 | |211-227 | 40 |335 |235 | |230 | 260 |336 |236 | |231-247 | 40 |337 |237 | |250 | 360 |340 |240 | |251-254 | 40 |341 |241 | |255 | 55 |342 |242 | |256-267 | 40 |343 |243 | |270 | 361 |344 |244 | |271-277 | 40 |345 |245 | |300 | 200 |346 |246 | |301 | 201 |347 |247 | |302 | 202 |350 |250 | |303 | 203 |351 |251 | |304 | 204 |352 |252 | |305 | 205 |353 |253 | |306 | 206 |354 |254 | |307 | 207 |355 |255 | |310 | 210 |356 |256 | |311 | 211 |357 |257 | |312 | 212 |360 |340 | |313 | 213 |361 |341 | |314 | 214 |362 |342 | |315 | 215 |363 |343 | |316 | 216 |364 |344 | |317 | 217 |365 |345 | |320 | 220 |366 |346 | |321 | 221 |367 |347 | |322 | 222 |370 |350 | |323 | 223 |371 |351 | |324 | 224 |372 |352 | |325 | 225 |373 |353 | |326 | 226 |374 |354 | |327 | 227 |375 |355 | |330 | 230 |376 |356 | |331 | 231 | | | +---------------+----------------+----------------+---------------+ MS 1251 to Mac Cyrillic For the conversion of MS 1251 to Mac Cyrillic, all characters not in the following table are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | MS 1251 | Mac Cyrillic | MS 1251 | Mac Cyrillic | |24 | 4 |260 |241 | |200 | 253 |262 |247 | |201 | 256 |263 |264 | |202 | 40 |264 |266 | |203 | 257 |266 |246 | |204 | 327 |267 |245 | |205 | 311 |270 |336 | |206 | 240 |271 |334 | |207-211 | 40 |272 |271 | |212 | 274 |273 |310 | |213 | 40 |274 |300 | |214 | 276 |275 |301 | |215 | 315 |276 |317 | |216 | 40 |277 |273 | |217 | 332 |300 |200 | |220 | 254 |301 |201 | |221 | 324 |302 |202 | |222 | 325 |303 |203 | |223 | 322 |304 |204 | |224 | 323 |305 |205 | |225 | 40 |306 |206 | |226 | 320 |307 |207 | |227 | 321 |310 |210 | |230 | 40 |311 |211 | |231 | 252 |312 |212 | |232 | 275 |313 |213 | |233 | 40 |314 |214 | |234 | 277 |315 |215 | |235 | 316 |316 |216 | |236 | 40 |317 |217 | |237 | 333 |320 |220 | |240 | 312 |321 |221 | |241 | 330 |322 |222 | |242 | 331 |323 |223 | |243 | 267 |324 |224 | |244 | 377 |325 |225 | |245 | 242 |326 |226 | |246 | 40 |327 |227 | |247 | 244 |330 |230 | |250 | 335 |331 |231 | |252 | 270 |332 |232 | |253 | 307 |333 |233 | |254 | 302 |334 |234 | |255 | 55 |335 |235 | |256 | 250 |336 |236 | |257 | 272 |337 |237 | |355 | 316 | | | +---------------+----------------+----------------+---------------+ FILES
/usr/lib/iconv/*.so conversion modules /usr/lib/iconv/*.t conversion tables /usr/lib/iconv/iconv_data list of conversions supported by conversion tables SEE ALSO
iconv(1), iconv(3C), iconv(5) SunOS 5.10 18 Apr 1997 iconv_1251(5)
All times are GMT -4. The time now is 10:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy