I know a little bit of sed and awk. If you guru can show me either one of the commands, greatly appreciated. I appreciate any help you can provide.
I tried
Code:
sed 's/............./&,/g'
and it insert comma (,) at every 14th position.
With problems like this, it is always a good idea to tell us what operating system and shell you're using. And, we need a clearer description of what constitutes a field in your input file and where the commas are to be inserted into your output. (I have no idea why the 1st two commas in the line marked in red above are positioned where they are???)
While it is true that the sed command you showed us adds a comma after every string of 13 characters found on each line of its input, I don't see how that is related to the output you displayed in the result you are trying to achieve.
It sort of looks like you have five fixed-width fields and any two of those fields might be missing from an input line. If all of the fields contain non-blank characters, you want to insert a comma at the end of the non-blank characters in fields 1, 2, and 4 if field 4 is present and after fields 1, 2, and 3 if field 4 is missing. And, if field 5 is present, a space is to be added to the end of field 5. But, as I mentioned before, if fields 1 and 2 do not contain any non-blank characters, I don't understand why the commas on that line are where they are in your desired result???
If you aren't on a system with GNU sed, or if the script disedorgue provided doesn't do what you need, please give us a much clearer specification of what you are trying to do and tell us what operating system and shell you're using.
This User Gave Thanks to Don Cragun For This Post:
Hi,
Newbie here. Need to convert a txt file to .csv format. There's no character to replace so not sure if I can use sed :confused: . The comma is to be inserted after every certain number of characters in each line...
Help!
Thanks. (4 Replies)
var=12345
echo $var >>>12345
printf "%8.1f \n" $var >>> 12345.0
How to get this as 12,345?
I suppose I could break into sections by dividing by 1000 or 1000000.
But, is the a trick to this? (4 Replies)
Hi All,
I have a file that contain value below:
test,mno,mno, +asc
mno,lok,msyu,tts
test,poi,test,0,90, 3,00
i need to substitute the comma's into pipe where i... (2 Replies)
Hi,
Newbie here. I have a file that consists of data that I want to convert to a csv file. For example:
Jul 20 2008 1111 / visit home / BlackBerry8830/4.2.2 Profile/MIDP-2.0 Configuration/CLOC-1.1 VendorID/105
Jul 21 2008 22222 / add friend / BlackBerry8830/4.2.2 Profile/MIDP-2.0... (3 Replies)
i have the below line as output from a script. I want to delete the string "," and get the output without comma,
cat D* | grep "bytes free" | awk '{print $3}' | ?????
output:
40,966,189,056
Desired O/P:
40966189056 (1 Reply)
Hi
I have a text file which is position delimited, i.e.
Code1 Description1 Value1
Code2 Description2 Value2 etc.
I want to import this file into MySQL so I want to convert the file into Comma delimited format.
To do this I want to insert commas at fixed positions on... (7 Replies)
Hi experts,
I would like a favour from you guys to get the info from 5th column which was separated by the delimeter comma ( , )
The Data file is as below:-
1,USER1,"90, TEST AVENUE, OLD ROAD",test1,124,N
2,USER2,88 TEST STREET NEW ROAD,test2,123,N
The User File is as below:-
USER1... (1 Reply)
Hey guys,
I have the following text:
1,2,3,4,5,6,'NULL','when',NULL,1,2,0,'NULL'
1,2,3,4,5,6,'NULL','what','NULL',1,2,0,1
I need the same text with the word NULL without commas
u know something like this:
1,2,3,4,5,6,NULL,'when',NULL,1,2,0,NULL
1,2,3,4,5,6,NULL,'what','NULL',1,2,0,1
... (1 Reply)
Hi,
I am trying to insert Inverted Commas around all the numeric values within a comma seperated string / variable.
1111,2222,3333,4444
I would like it to be:
'1111','2222','3333','4444'
Note - This string could have a differing amount of numeric values each time the variable is... (4 Replies)
Hi All,
I have a set of data as below :
XS012371378 Raj 23-09-12
SH128238948 Andrew 24-08-12
CH273712399 Walsh 12-10-12
JK7249923893 Nick 10-02-13
JP6383791389 Braslin 30-12-13
I want the first column to be extracted separately. I can get this using awk.
awk '{print $1}' file_name
... (3 Replies)