Sponsored Content
Full Discussion: sed to insert a character
Top Forums Shell Programming and Scripting sed to insert a character Post 302767395 by Chubler_XL on Wednesday 6th of February 2013 08:15:26 PM
Old 02-06-2013
Use '&' to insert matched string:

Code:
sed 's/^[0-9]/#&/'

 

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
DIALRULES(5)							File Formats Manual						      DIALRULES(5)

NAME
dialrules - HylaFAX dial string processing rules DESCRIPTION
A dial string specifies how to dial the telephone in order to reach a destination facsimile machine, or similar device. This string is supplied by a user with each outgoing facsimile job. User-supplied dial strings need to be processed in two ways by the HylaFAX server processes: to craft a canonical phone number for use in locating the receiver's capabilities, and to process into a form suitable for send- ing to a modem. In addition client applications may need to process a dial string to formulate an external form that does not include pri- vate information such as a credit card access code. Phone number canonicalization and dial string preparation are done according to dial string processing rules that are located in a file specified in the server configuration file; see the DialStringRules parameter in hylafax-config(5). The generation of an externalized form for a dial string is done by rules that optionally appear in /etc/hylafax/dial- rules on client machines. A dial string rules file is an ASCII file containing one or more rule sets. A rule set defines a set of transformation rules that are sequentially applied to a dial string. Each rule set is associated with an identifier, with certain well-known identifiers being used by the facsimile server or client application. Each transformation rule is a regular expression and a replacement string; the regular expres- sion is repeatedly applied to a dial string and any matching substring is replaced by the replacement string. The syntax of a dial string rules file is as follows. Comments are introduced with the ``!'' character and continue to the end of the cur- rent line. Identifiers are formed from a leading alphabetic and any number of subsequent alpha-numeric characters. A rule set is of the form: Identifier := [ rule1 rule2 ... ] where rule1, rule2, and so on are transformation rules. Line breaks are significant. The initial rule set definition line and the trail- ing ``]'' must be on separate lines; and each transformation rule must also be on a single line. Transformation rules are of the form: regular-expression = replacement where regular-expression is a POSIX 1003.2 extended regular expression and replacement is a string that is substituted in place of any por- tion of the dial string that is matched by the regular-expression. White space is significant in parsing transformation rules. If a regu- lar expression or replacement string has embedded white space in it, then the white space needs to be escaped with a ``'' character or the entire string should be enclosed in quote (``"'') marks. Replacement strings may reference the entire string matched by the regular expression with the ``&'' character. Substrings matched with the ``(...)'' constructs may be referenced by using `` '' where n is a sin- gle numeric digit between 1 and 9 that refers to the n-th matched substring; c.f. re_format(7), sed(1), etc. To simplify and parameterize the construction of rule sets, dial string rules files may also include simple text-oriented variable defini- tions. A line of the form: foo=string defines a variable named foo that has the value string. String values with embedded whitespace must use the ``'' character or be enclosed in quote marks. Variables are interpolated into transformation rules by referencing them as: ${var} Note that variable interpolation is done only once, at the time a transformation rule is defined. This means that forward references are not supported and that circular definitions will not cause loops. The facsimile server automatically defines four variables to have the values defined in its configuration file: AreaCode, CountryCode, LongDistancePrefix, and InternationalPrefix These variables are initial- ized before parsing a dial string rules file; thus if they are defined in the rules file then they will override any definition by the server. There are three well known rule set names: CanonicalNumber to convert a dial string to a canonical format, DialString to prepare a dial string before using it to dial the telephone, and DisplayNumber to convert a dial string to an external ``displayable'' form that does not include the private information that might appear in the raw dial string. EXAMPLES
This is the default set of rules for transforming a dial string into a canonical phone number: Area=${AreaCode} ! local area code Country=${CountryCode} ! local country code IDPrefix=${InternationalPrefix} ! prefix for placing an international call LDPrefix=${LongDistancePrefix} ! prefix for placing a long distance call ! ! Convert a phone number to a canonical format: ! ! +<country><areacode><rest> ! ! by (possibly) stripping off leading dialing prefixes for ! long distance and/or international dialing. ! CanonicalNumber := [ %.* = ! strip calling card stuff [abcABC] = 2 ! these convert alpha to numbers [defDEF] = 3 [ghiGHI] = 4 [jklJKL] = 5 [mnoMNO] = 6 [prsPRS] = 7 [tuvTUV] = 8 [wxyWXY] = 9 [^+0-9]+ = ! strip white space etc. ^${IDPrefix} = + ! replace int. dialing code ^${LDPrefix} = +${Country} ! replace l.d. dialing code ^[^+] = +${Country}${Area}& ! otherwise, insert canon form ] The first rule simply strips anything following a ``%''; this will remove any calling card-related information. The next eight rules con- vert upper and lower case alphabetics to the equivalent key numbers (this is convenient for users that use mnemonic phone numbers). The tenth rule removes everything but numbers and plus signs. The eleventh rule translates any explicit international dialing prefix into the ``+'' symbol used to identify country codes. The twelfth rule replaces a leading long distance dialing prefix with the local country code string. The last rule matches local phone numbers and inserts the local country code and area code. As an example, assume that AreaCode=415 CountryCode=1 InternationalPrefix=011 LongDistancePrefix=1 then if the above set of rules is applied to ``01123965-Tube%2345'', the transformations would be: 01123965-Tube%2345 01123965-Tube ! strip calling card stuff 01123965-Tube 01123965-8823 ! convert alphabetics 01123965-8823 011239658823 ! strip white space etc. 011239658823 +239658823 ! replace int. dialing code +239658823 +239658823 ! replace l.d. dialing code +239658823 +239658823 ! otherwise, insert canon form for a final result of ``+239658823''. SEE ALSO
sendfax(1), dialtest(8), faxq(8), faxsend(8), faxgetty(8), hylafax-config(5) May 8, 1996 DIALRULES(5)
All times are GMT -4. The time now is 01:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy