09-07-2008
Tough Substituion command
I have lines like:
Mg2.qns W=0.175u
Mg2.qpsb W=0.175u
Mg4.qns W=0.175u
Mg4.qpsb W=0.175u
Which I need to become:
Mg2.qns W=wmg2qns
Mg2.qpsb W=wmg2qpsb
Mg4.qns W=wmg4qns
Mg4.qpsb W=wmg4qpsb
To acheive this individually line by line I use a command like:
:g/Mg2\.qns/s/W=.*/W=wmg2qns/
However I wish to acheive this for all lines in one command
I can find all the lines containing the concerned words by using:
:g/Mg[24]\.q[np]s/s/??????????????????????
I do not know how to fill up the second part of the command represented by question marks. Any idea?
8 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Folks,
I've been trying to use the ENV variable with slashes(/) in its value inside the sed substitution..
Sed 's/myval/'$MYVAL'/' file1 >> file.tmp
If MYVAL=<sometext>, it works.
if MYVAL=/home/venkat, it doesnt.
***************************
bash-2.05$ export VAL=/home/venkat... (5 Replies)
Discussion started by: gvsreddy_539
5 Replies
2. Shell Programming and Scripting
@xray =~ s/^ *//g;
@xray =~ s/ *$//g;
@xray =~ s/\s+/ /g;
Guess I have a two part question ...
First
Is there a way to make substitutions, remove leading spaces, trailing spaces, and crunch multiple spaces into a single space, to the entire array, or must the substitutions be done on on... (1 Reply)
Discussion started by: popeye
1 Replies
3. Solaris
Dear All
i am getting "bad substituion" error in the follwing piece of code when i run from crontab.however it works if i run directly from my machine.
#!/bin/bash
for i in `cat abc`
do
part1=${i:0:12} ;
part2=${i:13:27} ;
echo "$part1,$part2">> def
done (1 Reply)
Discussion started by: asadlone
1 Replies
4. UNIX for Dummies Questions & Answers
I have a string as "Period= 20090531 Client Name= Clayton Lumbar Company Destination= MD"
I want to parse the string and store it in 3 different variables.
$period (should get value 20090531)
$client (should get value "Clayton Lumbar company")
$dest (should get value MD)
How can I do... (3 Replies)
Discussion started by: paruthiveeran
3 Replies
5. UNIX for Advanced & Expert Users
How Can this logic be implemented in Unix
SELECT
B.SERVICE_TYPE || '|' ||
B.TOTAL_TYPE || '|' ||
B.CALL_INDICATOR || '|' ||
B.A_NUMBER || '|' ||
B.APN || '|' ||
B.DAY || '|' ||
B.HOUR ||... (3 Replies)
Discussion started by: magedfawzy
3 Replies
6. Shell Programming and Scripting
hello everyone!:)
I have an exercise which I think is difficult for beginner like me. Here is the exercise
Create a shell script, which takes a directory as command line argument.
Script displays ten first lines from every text file in that directory. After
displaying the lines from the... (1 Reply)
Discussion started by: googlevn
1 Replies
7. Shell Programming and Scripting
I have a file with 20 blank spaces.
I want to substitute each blank space for a string, and part of that string should include an incremental number
Code
while read line3
do
awk -v var=${line3} '{i=var; sub("^]*$", "\\&\n@target G0.S"'$i'"\n@type xy"); print $0}'... (1 Reply)
Discussion started by: chrisjorg
1 Replies
8. UNIX for Beginners Questions & Answers
Hi Folks -
I'm getting the following error message when executing my script:
$ chmod +x Winexe_Admin.sh
$ ./Winexe_Admin.sh
Script Name: Winexe_Admin.sh
Script Name without EXT: Winexe_Admin
./Winexe_Admin.sh: line 43: ${_MAINPATH}${_LOGPATH}${LOGPATH$}${_YEAR}_${_MONTH}${_DAY}: bad... (2 Replies)
Discussion started by: SIMMS7400
2 Replies
colcrt(1) General Commands Manual colcrt(1)
NAME
colcrt - Filters text processor output for screen previewing
SYNOPSIS
colcrt [- -2] [file...]
The colcrt command filters output from text processors such as nroff so that it can be previewed on a cathode ray tube (CRT).
OPTIONS
Suppresses underlining; this is useful for previewing boxed tables from tbl. Causes all half-lines to be printed, effectively doublespac-
ing the output. This is useful when printing output with subscripts and superscripts on a line printer, where half-lines do not normally
appear.
DESCRIPTION
The colcrt command provides virtual half-linefeed and reverse linefeed sequences for terminals without such capability, and on which over-
striking is destructive. The colcrt command changes underline characters to dashes and places them and half-line characters on new lines in
between the normal output lines.
NOTES
colcrt cannot back up more than 102 lines. General overstriking is lost; as a special case a | (vertical bar) overstruck with a - (dash)
or _ (underline) becomes a + (plus sign). Lines are trimmed to 132 bytes.
EXAMPLES
The following command line illustrates a typical use of colcrt: tbl exum2.n | nroff -ms | colcrt - | more
SEE ALSO
Commands: col(1), deroff(1), more(1), neqn(1), nroff(1), pg(1), tbl(1), ul(1)
colcrt(1)