Is it possible to introduce a character using sed?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Is it possible to introduce a character using sed?
# 1  
Old 12-12-2012
Is it possible to introduce a character using sed?

I need to reformat a text using sed command like

Text: 160845
Output: 16:08:45

Please help me how this can be done using sed.
Thanks in adv
# 2  
Old 12-12-2012
Code:
echo 160845 | sed 's/\(..\)\(..\)/\1:\2:/'
16:08:45

This User Gave Thanks to Yoda For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed searches a character string for a specified delimiter character, and returns a leading or traili

Hi, Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank. Text file : "1"|"ExternalClassDEA519CF5"|"Art1" "2"|"ExternalClass563EA516C"|"Art3" "3"|"ExternalClass305ED16B8"|"Art9" ... ... ... (2 Replies)
Discussion started by: fspalero
2 Replies

2. Shell Programming and Scripting

How to introduce the missing number sequentially?

Dear Help, I have an input file which looks like below 002 1000 2000 3000 003 2000 3000 4000 005 1000 2000 6000 I would like to have an output which inserts the missing number in sequential sorting as shown below... 001 0 0 0 002 1000 2000 3000 003 2000 3000 4000 004 0 0 0 005 1000... (5 Replies)
Discussion started by: Indra2011
5 Replies

3. Shell Programming and Scripting

Sed: delete on each line before a character and after a character

Hi there, A total sed noob here. Is there a way using sed to delete everything before a character AND after another character on each line in a file? The deletion should also delete the indicating characters(here: an opening and a closing parenthesis). The original file would look like... (3 Replies)
Discussion started by: bnbsd
3 Replies

4. Solaris

Create files to introduce with ZFS

Hello, To learn ZFS, i try to create pool . and for that i want create 10 files with 512MB (because i dont have multiple disks and multiple controllers) ADMIT THAT THIS IS TEN HIGH-PERFORMANCE HARD DRIVES To get this 10 files,all of them have the same size : 512MB, I do these... (9 Replies)
Discussion started by: herbich1985
9 Replies

5. Shell Programming and Scripting

In Sed how can I replace starting from the 7th character to the 15th character.

Hi All, Was wondering how I can do the following.... I have a String as follows "ACCTRL000005022RRWDKKEEDKDD...." This string can be in a file called tail.out or in a Variable called $VAR2 Now I have another variable called $VAR1="000004785" (9 bytes long), I need the content of... (5 Replies)
Discussion started by: mohullah
5 Replies

6. Shell Programming and Scripting

how to introduce a space in a single column without distrubing the other columns

Hello Experts, I am new to this forum, I would like to do the following changes in one of the column of a txt file, which is having around 9 column. For example, column 3 is having letters like this AB11 AB12 C CA CB AC1 AC2 I would like to convert the same column as follows ... (5 Replies)
Discussion started by: Fredrick
5 Replies

7. UNIX for Dummies Questions & Answers

SED: Can't Repeat Search Character in SED Output

I'm not sure if the problem I'm seeing is an artifact of sed or simply a beginner's mistake. Here's the problem: I want to add a zero-width space following each underscore between XML tags. For example, if I had the following xml: <MY_BIG_TAG>This_is_a_test</MY_BIG_TAG> It should look like... (8 Replies)
Discussion started by: rhetoric101
8 Replies

8. UNIX for Dummies Questions & Answers

Let my introduce myself and one doubt!!!!

Hello, My name is John. I am from Spain and I am learning Linux and how to use it. I hope to learn more in this forum. I am developing a new application, and I have a doubt: Can I read a file, line by line, in C programm? Best regards. (1 Reply)
Discussion started by: webquinty
1 Replies

9. Shell Programming and Scripting

how to introduce delay in the script??(urgent)

Hi all, i would like to know how to introduce a delay in the execution of a cmd? am trying to copy a file which is about 650 mb and then perform some actions on it.. however since its huge i would like to introduce a delay in exection until the process is over i dont want it to proceed to... (10 Replies)
Discussion started by: wrapster
10 Replies
Login or Register to Ask a Question