Sponsored Content
Top Forums Shell Programming and Scripting Replace comma by space for specified field in record Post 302414151 by danmero on Monday 19th of April 2010 10:43:05 AM
Old 04-19-2010
Let's simulate:
Code:
# cat file
16458,99,001,"RIMOUSKI, QC",418,"N",7,EST,EDT,902
16458,99,002,"CHANDLER, QC",418,"N, C",5,MST,MDT,616
16458,99,003,"NEWRICHMND QC",418,"B, C",7,EST,EDT,702

# sed 's/,/ /4' file
16458,99,001,"RIMOUSKI  QC",418,"N",7,EST,EDT,902
16458,99,002,"CHANDLER  QC",418,"N, C",5,MST,MDT,616
16458,99,003,"NEWRICHMND QC" 418,"B, C",7,EST,EDT,702

# awk 'BEGIN{FS=OFS="\""}{sub(",",x,$2)}1' file
16458,99,001,"RIMOUSKI QC",418,"N",7,EST,EDT,902
16458,99,002,"CHANDLER QC",418,"N, C",5,MST,MDT,616
16458,99,003,"NEWRICHMND QC",418,"B, C",7,EST,EDT,702

# sed 's/, / /g' file
16458,99,001,"RIMOUSKI QC",418,"N",7,EST,EDT,902
16458,99,002,"CHANDLER QC",418,"N C",5,MST,MDT,616
16458,99,003,"NEWRICHMND QC",418,"B C",7,EST,EDT,702

# sed 's/"\([^"]*\),\([^"]*\)"/\1\2/g' file
16458,99,001,RIMOUSKI QC,418,"N",7,EST,EDT,902
16458,99,002,CHANDLER QC,418,N C,5,MST,MDT,616
16458,99,003,"NEWRICHMND QC,418B, C",7,EST,EDT,702

 

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

how to replace field for each record

Hello, I have the following xml formatted file. I would like to get the newnumber field number and replace into customernumber for each record. For example: <XMLFORMAT> <customernumberR11>9</customernumberR11> ... (12 Replies)
Discussion started by: happyv
12 Replies

3. Shell Programming and Scripting

How to replace all entries of comma in text file by space or other character

Hi , How to replace all entries of comma in text file by space or other character. cat temp.txt A,B,C,D I want this file to be like A B C D Please help!!! (4 Replies)
Discussion started by: prashant43
4 Replies

4. Shell Programming and Scripting

Replace third field of the first record in a file....

Hi, I am new to unix and am trying to do something below: I have a pipe delimited file with millions of records. I need to replace the third column of the first record to the number of lines in the file. How can I do that. Will appreciate any advice and help. Thanks Simi (3 Replies)
Discussion started by: simi28
3 Replies

5. Shell Programming and Scripting

replace space with comma in perl

arr_Ent_NameId variable holds 'Prakash pawar' 'sag' '23' '50000' this value 'Prakash pawar' 'sag' '23' '50000' I want to replace space( ) with comma (,) There are 4 fields here. I don't want to replace first field with comma. output should be: 'Prakash,pawar','sag','23','50000' ... (2 Replies)
Discussion started by: pritish.sas
2 Replies

6. Shell Programming and Scripting

Replace comma with a blank space using SED

Hello everyone, I want to replace all "," (commas) with a blank space My command thus far is: cat test.text | sed -e s/\`//g | awk '{print$1" "$2" "$3}' I'm sure you guys know this, but the SED command that I am using is to get rid of the "`" (tics). which gives me: name ... (5 Replies)
Discussion started by: jayT
5 Replies

7. Shell Programming and Scripting

replace 3rd field of space delimited text file

how to replace the 3rd colum? Each line begins similarly, but they all ends variously. XX YY 03 variable text here XX YY 03 more variable text here XX YY 03 even more variable text here really long setence XX YY 03 variable numbers also appear 03 11. 123 456 XX YY 03 the occasional comma,... (4 Replies)
Discussion started by: ajp7701
4 Replies

8. Shell Programming and Scripting

Replace field in one file with whole record data of another

Hello Group, I need to replace the city field in “File 1 (fileld 3), with the entire record line of “File 2” (including delimiters) where the “city” field (File 1, Field 3)matches city field (File 2, Field1). All of the other data in “File 1” should remain intact(Fields 1,2,4,5,6). Only field... (1 Reply)
Discussion started by: vestport
1 Replies

9. Shell Programming and Scripting

Script using awk to replace space by comma

I have the content of this file that i would like to replace the space by comma. The file content values in this format FName LName Date & time ------------------------------------ Gilles John 14/12/17 12:30:45 I want this format Fname,LName,Date&time... (7 Replies)
Discussion started by: gillesi
7 Replies

10. Shell Programming and Scripting

How to replace value in each field until a certain character in each record?

Each record coming with column names. I have to replace them in each record as shown below TIME=20181219110000261|CHAN=FMBKHJBAAAADPCFNAAAAAABA|EVNT=SWIclst|VALU=Session FMBKHJBAAAADPCFNAAAAAABA started|SRC=NSS|UCPU=0|SCPU=0 Output should look like: ... (9 Replies)
Discussion started by: sudhakar1987
9 Replies
clacon.f(3)							      LAPACK							       clacon.f(3)

NAME
clacon.f - SYNOPSIS
Functions/Subroutines subroutine clacon (N, V, X, EST, KASE) CLACON Function/Subroutine Documentation subroutine clacon (integerN, complex, dimension( n )V, complex, dimension( n )X, realEST, integerKASE) CLACON Purpose: CLACON estimates the 1-norm of a square, complex matrix A. Reverse communication is used for evaluating matrix-vector products. Parameters: N N is INTEGER The order of the matrix. N >= 1. V V is COMPLEX array, dimension (N) On the final return, V = A*W, where EST = norm(V)/norm(W) (W is not returned). X X is COMPLEX array, dimension (N) On an intermediate return, X should be overwritten by A * X, if KASE=1, A**H * X, if KASE=2, where A**H is the conjugate transpose of A, and CLACON must be re-called with all the other parameters unchanged. EST EST is REAL On entry with KASE = 1 or 2 and JUMP = 3, EST should be unchanged from the previous call to CLACON. On exit, EST is an estimate (a lower bound) for norm(A). KASE KASE is INTEGER On the initial call to CLACON, KASE should be 0. On an intermediate return, KASE will be 1 or 2, indicating whether X should be overwritten by A * X or A**H * X. On the final return from CLACON, KASE will again be 0. Author: Univ. of Tennessee Univ. of California Berkeley Univ. of Colorado Denver NAG Ltd. Date: November 2011 Further Details: Originally named CONEST, dated March 16, 1988. Last modified: April, 1999 Contributors: Nick Higham, University of Manchester References: N.J. Higham, 'FORTRAN codes for estimating the one-norm of a real or complex matrix, with applications to condition estimation', ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988. Definition at line 115 of file clacon.f. Author Generated automatically by Doxygen for LAPACK from the source code. Version 3.4.1 Sun May 26 2013 clacon.f(3)
All times are GMT -4. The time now is 10:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy