Sponsored Content
Top Forums Shell Programming and Scripting Suppressing space replacing by comma Post 302414102 by posix on Monday 19th of April 2010 08:55:13 AM
Old 04-19-2010
replace multiple space with comma.

Quote:
Originally Posted by raghavendra.cse
Both are not working !
what ever solution is posted as per your previous requirement. But u changed the space with multiple space..
now you can try
Code:
sed 's/\s\+/,/g' file_name

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replacing comma's with newlines using sed

Hi All, silly question that I'm sure is easy to answer for a more experienced coder... I have a file called test.txt containing the following text... need, to, break, this, line, into, individual, lines using sed, I'd like to make the file look like this... need to break this line... (5 Replies)
Discussion started by: newbie_coder
5 Replies

2. UNIX for Dummies Questions & Answers

Replacing Comma by Tab

Hi All, i have a file test.txt as shown below, 1,test,test111 2,rest,rest222 i want to replace the commas by tab delimiter.., it should be like, 1 test test111 2 rest rest222 i tried the following code, sed 's/,/\\t/g' test.txt >> ouptut.txt (9 Replies)
Discussion started by: Serious Sam
9 Replies

3. Shell Programming and Scripting

Replacing dot for comma

I wanted to change 34.66 to 34,66. I tried the command: sed 's/./,/' $NUM Where $NUM is a variable with 34.66 value. The output is ,4.66 (2 Replies)
Discussion started by: bdalmeida
2 Replies

4. UNIX for Dummies Questions & Answers

Replacing underscore with white space after comma.

Hi all, I'm hoping you can help.. I've used this forum a couple of times and I am back again now i've moved onto something more complex (for me!) I have some data which looks like: "AL1_1,AL1_1," "AL1_1.AL1_1A.AL1_1AE,AL1_1AE," "AL1_1.AL1_1A.AL1_1AG,AL1_1AG," "AL1_1.AL1_1A.AL1_1AJ,AL1_1AJ,"... (10 Replies)
Discussion started by: gman
10 Replies

5. Shell Programming and Scripting

sed help - replacing 6th comma with a space

Hi, How can I replace the 6th comma on each line (of a csv) with a space? Any online tutorials with plenty of examples using sed would be very useful. Alex (2 Replies)
Discussion started by: mcclunyboy
2 Replies

6. UNIX for Advanced & Expert Users

Replacing the comma in .csv file in unix

Hi All, Could some one help me on one of my requirement below: I have a sequential file with 4fields in it and it is a comma (,) seperated file. Delimeter is 'comma'. But in of the file column for ex: 3rd column it is 'Description' (column name) I am getting the values with commas.... (6 Replies)
Discussion started by: eskay_s
6 Replies

7. Shell Programming and Scripting

Replacing Comma delimiter coming inside the data.

Hello, I am having flat file (Comma Delimiter) and the data in the file is as given below. EMPNO, ENAME, DESIGNATION, SALARY 10979, Arun Kumar, Cosultant, 35000 13555, Bidhu Shekar, Senior Consultant, 45000 15000, Kiran, Kumar, Senior, Consultant, 40000 If... (9 Replies)
Discussion started by: arunvasu2
9 Replies

8. UNIX for Dummies Questions & Answers

Replacing | with a comma

I have a huge file which is pipe delimiter and i want to replace the pipe delimiter to a comma Please Help as its v urgent. Ex: parent|child|alias|....Heading of the file...and the data is of similar structure. (4 Replies)
Discussion started by: win4luv
4 Replies

9. Shell Programming and Scripting

Need help with Sed (replacing parenthesis and comma)

I have the following text as an input text: input.txt Results('Toilet', 'Sink', ) and i want to remove the last comma so the output is output.txt Results('Toilet', 'Sink' ) I tried using the following sed command, but I get a parsing error: sed s/, \)/\)/g input.txt >... (5 Replies)
Discussion started by: jl487
5 Replies

10. Shell Programming and Scripting

Add previous text when replacing comma with new line

Hi, I've got this output: # cat test2.txt TM1ITP1-TMNLSTP1 SLC00=0,SLC01=0,SLC02=0,SLC03=0 if I just use cat test2.txt | tr "," "\n" I'll end up very near to what I'm trying to achieve: TM1ITP1-TMNLSTP1 SLC00=0 SLC01=0 SLC02=0 SLC03=0 But how can i eventually add the term... (1 Reply)
Discussion started by: nms
1 Replies
WC(1)							    BSD General Commands Manual 						     WC(1)

NAME
wc -- word, line, character, and byte count SYNOPSIS
wc [-clmw] [file ...] DESCRIPTION
The wc utility displays the number of lines, words, and bytes contained in each input file (or standard input, by default) to the standard output. A line is defined as a string of characters delimited by a <newline> character, and a word is defined as a string of characters delimited by white space characters. White space characters are the set of characters for which the iswspace(3) function returns true. If more than one input file is specified, a line of cumulative counts for all the files is displayed on a separate line after the output for the last file. The following options are available: -c The number of bytes in each input file is written to the standard output. -l The number of lines in each input file is written to the standard output. -m The number of characters in each input file is written to the standard output. If the current locale does not support multibyte characters, this is equivalent to the -c option. -w The number of words in each input file is written to the standard output. When an option is specified, wc only reports the information requested by that option. The default action is equivalent to specifying the -c, -l and -w options. If no files are specified, the standard input is used and no file name is displayed. ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of wc as described in environ(7). EXAMPLES
Count the number of characters, words and lines in each of the files report1 and report2 as well as the totals for both: wc -mlw report1 report2 DIAGNOSTICS
The wc utility exits 0 on success, and >0 if an error occurs. SEE ALSO
iswspace(3) COMPATIBILITY
Historically, the wc utility was documented to define a word as a ``maximal string of characters delimited by <space>, <tab> or <newline> characters''. The implementation, however, didn't handle non-printing characters correctly so that `` ^D^E '' counted as 6 spaces, while ``foo^D^Ebar'' counted as 8 characters. 4BSD systems after 4.3BSD modified the implementation to be consistent with the documentation. This implementation defines a ``word'' in terms of the iswspace(3) function, as required by IEEE Std 1003.2 (``POSIX.2''). STANDARDS
The wc utility conforms to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
A wc command appeared in Version 1 AT&T UNIX. BSD
June 13, 2002 BSD
All times are GMT -4. The time now is 12:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy