Sponsored Content
Full Discussion: vi substitution
Top Forums Shell Programming and Scripting vi substitution Post 302469472 by drareeg on Saturday 6th of November 2010 11:48:37 AM
Old 11-06-2010
vi substitution

Hello, I'm trying to do a substitution in vi. which adds a field for the year to a line.
If the line doesnt include a year, it should still add a field (although empty)

the fields are:
Country:number:number:name(and sometimes year)Smilielace
this is a desired in and output:
Code:
 
Sweden:55:32:John 1898 cyclone:Kortsnau
Belize:73:27:Dolal 01:Bodville
should become
Sweden:55:32:John 1898 cyclone:1898:Kortsnau
Belize:73:27:Dolal 01::Bodville

I dont know how you can place a wildcard on a group: I tried this:
Code:
:1,$s/^\(.* \)\([0-9][0-9][0-9][0-9]\)*\(.*\):\(.*\)$/\1\2\3:\2:\4/g

can anybody tell me how it is done porperly?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

substitution

I am trying to substituted a variable to a file using sed. However, the value of that variable is not being substituted. Here is an example of my code. lf=' ' v_whole="${1} ${2} ${3} $lf" cp ${IPPDIR}/ctl/fax_sub_text_a.${4}.${5}.txt... (1 Reply)
Discussion started by: supercbw
1 Replies

2. UNIX for Dummies Questions & Answers

Need help in substitution!!!!

In a file I want to globally change a "|" charater by a new line character. I am using the command 1,$s/\|/??/g Can anybody say what should I put in place of ?? in the above command? (3 Replies)
Discussion started by: uLearner
3 Replies

3. Shell Programming and Scripting

Substitution using SED

Hi , I am stuck up in the below scenario:- I need to read a file name (eg A.txt) name frm another file (eg B.txt) and then I need to search for a particular expression in A.txt and substitute it with another expression. How can I use SED inside SHELL Scripting and command prompt as... (2 Replies)
Discussion started by: shubhranshu
2 Replies

4. Shell Programming and Scripting

SED Substitution

Hi , I am stuck up in the below scenario:- I need to read a file name (eg A.txt) name frm another file (eg B.txt) and then I need to search for a particular expression in A.txt and substitute it with another expression. How can I use SED inside SHELL Scripting and command prompt as well to... (1 Reply)
Discussion started by: shubhranshu
1 Replies

5. Shell Programming and Scripting

Difference between "Command substitution" and "Process substitution"

Hi, What is the actual difference between these two? Why the following code works for process substitution and fails for command substitution? while IFS= read -r line; do echo $line; done < <(cat file)executes successfully and display the contents of the file But, while IFS='\n' read -r... (3 Replies)
Discussion started by: royalibrahim
3 Replies

6. Shell Programming and Scripting

Substitution

All, I have this text document that contains a listing(See below). What i would like to ask is how i could extract just the information i need which is the files name (CWS*****.***.gz) If anyone has any suggestions i would be very grateful. I am sure its relatively simple but i just... (6 Replies)
Discussion started by: Andyp2704
6 Replies

7. UNIX for Dummies Questions & Answers

help with substitution

Hello, I have a file with 10,000+ records which look like this: Image3992170.tif 4/21/200811:42:09AM 3,373.13KB Image3993265.tif 4/11/20087:17:58PM 2,369.72KB Image3996764.tif 5/2/200811:01:28AM 2,155.87KB Image3997700.tif ... (4 Replies)
Discussion started by: lotusdeva
4 Replies

8. Shell Programming and Scripting

substitution help

How do i substitute ' with space in a file using sed or awk i am getting the following two scenarios 1) xyz'd with xyz d if i use sed 's/xyz\\\'d/xy z/g' it is taking ' after \ as closing expr for substitution 2) xyz';d with xyz d please advice (8 Replies)
Discussion started by: mad_man12
8 Replies

9. UNIX for Dummies Questions & Answers

vi substitution help

Hi experts, Could someone help me how to figure out the following substitution? I copied and pasted a column of names from an Excel file into another file in vi. The column of data has last names with dash (hyphens) and apostrophes. My goal is to do the following: 1) remove the apostrophes... (10 Replies)
Discussion started by: onlinelearner02
10 Replies

10. Shell Programming and Scripting

Substitution

I am trying to do some substitutions using the substitution operator (:%s) in a text file. I want to replace all A1, A2, A3.......A100 in my text file. I used :%s/A2/SAE/g successfully until A9 but when I use A1, all the A11 to A19 is changed. How do I specify the exact match here? (8 Replies)
Discussion started by: Kanja
8 Replies
deb-substvars(5)						  dpkg utilities						  deb-substvars(5)

NAME
deb-substvars - Debian source substitution variables SYNOPSIS
substvars DESCRIPTION
Before dpkg-source, dpkg-gencontrol and dpkg-genchanges write their control information (to the source control file .dsc for dpkg-source and to standard output for dpkg-gencontrol and dpkg-genchanges) they perform some variable substitutions on the output file. A variable substitution has the form ${variable-name}. Variable names consist of alphanumerics, hyphens and colons and start with an alphanumeric. Variable substitutions are performed repeatedly until none are left; the full text of the field after the substitution is rescanned to look for more substitutions. After all the substitutions have been done each occurrence of the string ${} (which is not a legal substitution) is replaced with a $ sign. While variable substitution is done on all control fields, some of those fields are used and needed during the build when the substitution did not yet occur. That's why you can't use variables in the Package, Source and Architecture fields. Variable substitution happens on the content of the fields after they have been parsed, thus if you want a variable to expand over multiple lines you do not have to include a space after the newline. This is done implicitly when the field is output. For example, if the variable ${Description} is set to "foo is bar.${Newline}foo is great." and if you have the following field: Description: foo application ${Description} . More text. It will result in: Description: foo application foo is bar. foo is great. . More text. Variables can be set using the -V common option. They can be also specified in the file debian/substvars (or whatever other file is speci- fied using the -T option). This file consists of lines of the form name=value. Trailing whitespace on each line, blank lines, and lines starting with a # symbol (comments) are ignored. Additionally, the following standard variables are available: Arch The current build architecture (from dpkg --print-architecture). source:Version The source package version. source:Upstream-Version The upstream source package version, including the Debian version epoch if any. binary:Version The binary package version (which may differ from source:Version in a binNMU for example). Source-Version The source package version (from the changelog file). This variable is now deprecated as its meaning is different from its function, please use the source:Version or binary:Version as appropriate. Installed-Size The total size of the package's installed files. This value is copied into the corresponding control file field; setting it will modify the value of that field. If this variable isn't set dpkg-gencontrol will use du -k debian/tmp to find the default value. Extra-Size Additional disk space used when the package is installed. If this variable is set its value is added to that of the Installed-Size variable (whether set explicitly or using the default value) before it is copied into the Installed-Size control file field. F:fieldname The value of the output field fieldname (which must be given in the canonical capitalisation). Setting these variables has no effect other than on places where they are expanded explicitly. Format The .changes file format version generated by this version of the source packaging scripts. If you set this variable the contents of the Format field in the .changes file will change too. Newline, Space, Tab These variables each hold the corresponding character. shlibs:dependencyfield Variable settings with names of this form are generated by dpkg-shlibdeps. dpkg:Upstream-Version The upstream version of dpkg. dpkg:Version The full version of dpkg. If a variable is referred to but not defined it generates a warning and an empty value is assumed. FILES
debian/substvars List of substitution variables and values. BUGS
The point at which field overriding occurs compared to certain standard output field settings is rather confused. SEE ALSO
dpkg(1), dpkg-genchanges(1), dpkg-gencontrol(1), dpkg-shlibdeps(1), dpkg-source(1). Debian Project 2009-07-15 deb-substvars(5)
All times are GMT -4. The time now is 11:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy