Sponsored Content
Top Forums Shell Programming and Scripting How to replace NewLine with comma using sed? Post 302828517 by Scott on Tuesday 2nd of July 2013 03:39:34 PM
Old 07-02-2013
It should work. Perhaps you have whitespace after the last ,?

Code:
$ sed 's/,[[:blank:]]*$/,NULL/' file

(or use a literal space and tab inside a single [ and ] if your sed doesn't support character classes.)
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed utility to replace /307 with comma

Hi, I have a requirement to replace '/307' with comma ',' . for e.g. : $ cat dm.dat ------------- decimdal("\307") acct $echo $l \307 $echo $k , $sed -e "s/$l/$k/" dm.dat > dm1.dat sed: Function s/\307/,/ cannot be parsed. I want dm1.dat to be : $ cat dm1.dat (1 Reply)
Discussion started by: obedkhan
1 Replies

2. 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

3. Shell Programming and Scripting

Using sed I want to replace space by newline

Input: -------------------------- 123asd 456sdasda 789a ------------------------- output wanted: --------------------- 123asd 456sdasda 789a ---------------------- I want this by sed in simple way please help (I know by: tr ' ' '\n' < inputfile )I want it by sed only (5 Replies)
Discussion started by: RahulJoshi
5 Replies

4. 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

5. 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

6. Shell Programming and Scripting

Script using Sed :Search all patterns & after the last Patter, insert a newLine with Comma Sep Value

I am trying to search the pattern "ARS (11)" and after the LAST pattern, i am trying to open new line and enter text using sed. My Existing Text file is Users.txtpaul, Paul Smith, Stevn Smiley, REQ000001, ARS (11) sam, Sam Martin, Stevn Smiley, REQ000001, ARS (11) mike, Mike Conway, Stevn... (8 Replies)
Discussion started by: evrurs
8 Replies

7. Shell Programming and Scripting

Sed, replace comma with pipe. but ignore qoutes

hi, I am trying to replace comma with pipe, but the issue is that i want to ignore the commas inside qoutes. for example: i have file with the string: 1,"2,3",4,"5","6,7" the result should be : 1|"2,3"|4|"5"|"6,7" i trying to use sed and awk (match function) for that, but i did not... (4 Replies)
Discussion started by: gabik
4 Replies

8. Shell Programming and Scripting

Replace comma delimiter by newline

The input file is as below AR,age,marks,roll,section,evin,25,80,456,A,atch,23,56,789,B,eena,24 ,78H245,C,Ps,ot,ecessary,hat,ame comes first then age and rest AR AZ,kevin,25,80,456,A,Satch,23,56,789,Satch,23,56,789,B,Meena,24,78,H245,C,AZ ................ ................ I am writting... (8 Replies)
Discussion started by: millan
8 Replies

9. Shell Programming and Scripting

Command to replace newline with comma

Hi Experts, I need an urgent help in replacing newline characters in my single column file by a comma. I am using following command for this purpose: sed -n -e 'H;${x;s/\n/,/g;s/^,//;p;}' parameter.rtf | rev | cut -c 4- | revMy input file has: TABLE_1 TABLE_2 TABLE_3 What I need:... (11 Replies)
Discussion started by: neerndg123
11 Replies

10. UNIX for Beginners Questions & Answers

Replace newline with comma and append quotes

Hi, I have below requirement. Apple Orange Banana Required O/p in bash 'Apple,Orange,Banana' Can you please help. Please wrap your samples, codes in CODE TAGS as per forum rules. (3 Replies)
Discussion started by: Rtk
3 Replies
ctype(3C)																 ctype(3C)

NAME
ctype: isalnum(), isalpha(), isascii(), isblank(), iscntrl(), isdigit(), isgraph(), islower(), isprint(), ispunct(), isspace(), isupper(), isxdigit() - classify characters according to type SYNOPSIS
DESCRIPTION
These functions classify character-coded integer values according to the rules of the coded character set identified by the last successful call to (see setlocale(3C)). Each function is a predicate returning nonzero for true, zero for false. If has not been called successfully, characters are classified according to the rules of the default ASCII 7-bit coded character set (see setlocale(3C)). is defined on all integer values; the other functions are defined for the range (EOF) through RETURN VALUE
The functions return nonzero under the following circumstances; zero otherwise: c is an alphanumeric (letters or digits). c is a letter. c is any ASCII character code between 0 and 0177, inclusive. c is a blank character; that is, a space or a tab. c is a control character (in ASCII: character codes less than 040 and the delete character(0177)). c is a decimal digit (in ASCII: characters [0-9]). c is a visible character (in ASCII: printing characters, excluding the space character(040)). c is a lowercase letter. c is a printing character. c is a punctuation character (in ASCII: any printing character except the space character(040), digits, letters). c is a character that creates whitespace in displayed text (in ASCII: space, tab, carriage return, newline, verti- cal tab, and formfeed). c is an uppercase letter. c is a hexadecimal digit (in ASCII: characters [0-9], [A-F] or [a-f]). If the argument to any of these functions is outside the domain of the function, the result is undefined. EXTERNAL INFLUENCES
Environment Variables The category determines the classification of character type. International Code Set Support Single-byte character code sets are supported. WARNINGS
These functions are supplied both as library functions and as macros defined in the header. Normally, the macro versions are used. To obtain the library function, either use a to remove the macro definition or, if compiling in ANSI-C mode, enclose the function name in parenthesis or take its address. The following example uses the library functions for and AUTHOR
was developed by IBM, OSF, and HP. SEE ALSO
setlocale(3C), ascii(5), thread_safety(5). STANDARDS CONFORMANCE
ctype(3C)
All times are GMT -4. The time now is 08:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy