Sponsored Content
Full Discussion: sed to insert a character
Top Forums Shell Programming and Scripting sed to insert a character Post 302767393 by kaav06 on Wednesday 6th of February 2013 08:06:34 PM
Old 02-06-2013
sed to insert a character

Hi all,

I have a file like this
Code:
Q8N302
21-84
Q8N157
15-45
Q99996
167-201
202-251
269-318

I want to insert a character or space if the line starts with a number and I used the command
Code:
sed 's/^[0-9]/#/'

But in the output file, when it inserts this character, first digit in the number is deleted. How can I change the code so that I dont lose any digits. The output I am getting is given below

Code:
Q8N302
#1-84
Q8N157
#5-45
Q99996
#67-201
#02-251
#69-318
#20-321
#22-323

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How can I insert character to end of file?

Hello all How can I insert character to the end of text file without opening it in vi Just simple one liner, can it be done? Tnx (1 Reply)
Discussion started by: umen
1 Replies

2. UNIX for Dummies Questions & Answers

Insert character in the line

Hi All, I have below type file. abc|asd|pqr|2|2|2 asc|qwe|scf|5|4|4 Pipe location and count is dynamic and coming from a variable. I want to change it to below files. (chnage the first pipe to 3 pipes) abc|||asd|pqr|2|2|2 asc|||qwe|scf|5|4|4 (chnage the second pipe to 4 pipes)... (1 Reply)
Discussion started by: swat
1 Replies

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

4. Shell Programming and Scripting

insert character in particular position.

I want to insert space in 7th position of all the lines usign vi editor or sed command Input file 12345689010 abcdefghijk . . Output file 123456 89010 abcdef ghijk . . (7 Replies)
Discussion started by: Jairaj
7 Replies

5. Shell Programming and Scripting

Insert a character before a line

I have a file and I can get the line with a specific pattern. I want to inset # on start of the line. file.text ==== aa bb cc bb hh kk kk ll yy dd aa kk rr tt aa I want to comment out the line with contain "aa" after running the script file.text ==== #aa bb cc bb hh kk kk ll... (7 Replies)
Discussion started by: Biplab
7 Replies

6. Shell Programming and Scripting

Insert New Line Character

Hi, If my first character of a line starts with 2 then after 5th charecter newline character should be inserted. Input.txt: a1234567890 2222300007 bsdfsdf888999999 ssdfkjskfdjskfdjd 2899900000000099999999999999 28887777 999999999999999999 Output.txt: a1234567890 22223 00007... (8 Replies)
Discussion started by: unme
8 Replies

7. UNIX for Dummies Questions & Answers

Insert sign every n character (awk)

Hi, For example, I would like to insert a pipe every 4 characters for each second field (including after the last block). input (coma separated): line1,AAAABBBBCCCCDDDDEEEE line2,FFFFGGGGHHHHIIIIJJJJ output: line1,AAAA|BBBB|CCCC|DDDD|EEEE| line2,FFFF|GGGG|HHHH|IIII|JJJJ| my... (2 Replies)
Discussion started by: beca123456
2 Replies

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

9. UNIX for Beginners Questions & Answers

How to insert new line after a specific character in scripts?

Hi, I'm trying to add a new line after finding a specific String. That is my string: volumes: - ${DIR_WORK}/loadbalancer/html:/var/www/html and I want to change that file to: volumes: - ${DIR_WORK}/loadbalancer/html:/var/www/html extra_hosts: -... (4 Replies)
Discussion started by: siamak
4 Replies

10. UNIX for Beginners Questions & Answers

How to use sed to insert character in the beginning of file path?

I need to manipulate one Database file on Solaris 11 in which contains more than 5000 lines of data file path like this: '/data1/oradata/DBNAME/system01.dbf', '/data7/oradata/DBNAME/undotbs1_01.dbf', '/data1/oradata/DBNAME/sysaux01.dbf', '/data28/oradata/DBNAME/userdata01.dbf', ... (6 Replies)
Discussion started by: duke0001
6 Replies
Locale::Codes::LangExt(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangExt(3pm)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language extensions. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 Locale::Codes::LangExt(3pm)
All times are GMT -4. The time now is 07:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy