Sponsored Content
Full Discussion: Substitution
Top Forums Shell Programming and Scripting Substitution Post 302879444 by Kanja on Thursday 12th of December 2013 01:12:25 PM
Old 12-12-2013
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
Code:
 :%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?
 

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. Shell Programming and Scripting

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):place this is a desired in and output: Sweden:55:32:John... (2 Replies)
Discussion started by: drareeg
2 Replies

10. 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
XtFindFile()															      XtFindFile()

Name
  XtFindFile - search for a file using substitutions in a path.

Synopsis
  String XtFindFile(path, substitutions, num_substitutions, predicate)
	   String path;
	   Substitution substitutions;
	   Cardinal num_substitutions;
	   XtFilePredicate predicate;

Inputs
  path	    Specifies a path of file names including substitution characters.

  substitutions
	    Specifies a list of substitutions to make into the path.

  num_substitutions
	    Specifies the number of substitutions passed in.

  predicate Specifies a procedure called to judge each potential file name, or NULL.

Returns
  A filename, or NULL if no file was found.

Availability
  Release 4 and later.

Description
  XtFindFile()	performs the substitutions specified by substitutions on each colon-separated element of path in turn, and passes the result-
  ing string to predicate.  If predicate returns True, XtFindFile() returns the  string.   If  predicate  never  returns  True,  XtFindFile()
  returns NULL.

  Each	element  in substitutions is a structure that contains a character and a string.  If any element in path contains a percent sign fol-
  lowed by a character that appears in substitutions, then that two-character sequence will be replaced by the corresponding string  in  sub-
  stitutions.  The "Background" section below provides more details about the substitution process.

  If  predicate  is  NULL,  then  an  internal predicate is used that returns True if the string is the name of a readable file (and is not a
  directory), and returns False otherwise.  See XtFilePredicate(2) for more details on how to write a file predicate procedure.

  The caller must free the returned string with XtFree() when it is no longer needed.

Usage
  XtFindFile() is intended as a way to find a file that depends on variables such as the current setting of the locale, or the number of bit-
  planes  available on a screen.  Most applications can use the higher-level function XtResolvePathname() which provides a number of standard
  substitutions and a default path.

  The default predicate procedure is sufficient for most uses.	An application that wanted to find a directory rather than a file, for	exam-
  ple, would have to specify a custom predicate, as would an application that wanted to verify that a file was readable and that the contents
  of the file were reasonable would also have to provide a custom predicate procedure.

Background
  There are two substitution sequences that are treated specially:

  o  The character sequence %: (percent colon) specifies an embedded colon that is not a delimiter; the sequence  is  replaced	by  a  single
     colon.

  o  The  character  sequence  %%  (percent  percent)  specifies  a percent character that does not introduce a substitution; the sequence is
     replaced by a single percent character.

  A substitution string entry of NULL is equivalent to a pointer to an empty string.

  If the operating system does not interpret multiple embedded name separators in the path (i.e., "/" in POSIX) the same way as a single sep-
  arator,  XtFindFile() will collapse multiple separators into a single one after performing all string substitutions.	Except for collapsing
  embedded separators, the contents of the string substitutions are not interpreted by XtFindFile() and may therefore contain any  operating-
  system-dependent characters, including additional name separators.

Structures
  The Substitution type is defined as follows:

     typedef struct {
	 char match;
	 String substitution;
     } SubstitutionRec, *Substitution;

See Also
  XtResolvePathname(1),
  XtFilePredicate(2).

Xt - File Searching														      XtFindFile()
All times are GMT -4. The time now is 09:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy