02-12-2009
sed substitution problem
Can anyone please help me on this.
i have a file with lines say
X X3200 X
X X
X2400 X X4100
I want to use sed to put the numbers in braces.
the output should be like,
X X(3200) X
X X
X(2400) X X(4100)
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I know we can substitute a string using sed but how?
For example: sed 's/(old variable)/(new variable)/ details.dat
Am I suppose to put $old variable or whatever? Because I tried many times, it didnt work by putting $old variable. Am I suppose to enclose it with "" or ''?
Please help (3 Replies)
Discussion started by: Ohji
3 Replies
2. Shell Programming and Scripting
Hi,
heres my problem:
echo "aaaa(aaaa(aaa" | sed 's/a.*(//g'
gives aaa
but it should give aaaa(aaa
.*( should find any string to the appearance of (, but it finds any string to the last appearance, any idea why, and how to do this?
and what if the string ist... (2 Replies)
Discussion started by: funksen
2 Replies
3. Shell Programming and Scripting
I have file.txt
1 4 7 9 3
I want to replace the tabs with a space, but my code doesn't work.
cat file.txt | sed 's/"\t"/ /g' > t.txt
But file is still the same. Numbers seperated by tabs instead of spaces.
Help? (2 Replies)
Discussion started by: Bandit390
2 Replies
4. Shell Programming and Scripting
Hi I am trying to do a text insertion in a text file at a particular line number in a shell script. However its not working.
sed '122i\
> for j in \`echo $MyList\` ; do perl -pi -e\'s#01\/01\/2009#01\/01\/2011#\' $j ; done' $HOME/MyScript.ksh
The Actual line to be inserted at line 122... (5 Replies)
Discussion started by: som.nitk
5 Replies
5. Shell Programming and Scripting
Hi,
I am facing a strange problem. I have a script that used the following to search and replace text:
sed 's/'"${find_var_parm}"'/'"${find_var_filter}"'/g' $ParmFile > $TempFile
The values of $find_var_parm and $find_var_filter are set based on search criteria. The above seems to be working... (2 Replies)
Discussion started by: arsh
2 Replies
6. Shell Programming and Scripting
Using sed I'm trying to replace 'string' with ']' while retaining case and ignoring words with 'string' in it along with additional characters like 'strings' and those which already contain the ] wrapper. I'm hoping to do it with sed and the right expression, if possible.
Example:
Apple... (2 Replies)
Discussion started by: tom.lee
2 Replies
7. UNIX for Dummies Questions & Answers
I'm a noob to unix, and I have a line of data like the following:
title=Boston|tcolor=green|desc=Large city in New England|url=www.boston.com
Is there a way to change a field value with sed substitution?
(i.e. change tcolor=green to tcolor=blue)
I figured out: sed... (19 Replies)
Discussion started by: stabby
19 Replies
8. Shell Programming and Scripting
I have a file with some numbers having single quotes around them which I want to remove.
i.e. '923930' -> 23930
If it can be done without using sed thats fine. I have tried with sed but can't think how to replace this pattern on only the numbers (13 Replies)
Discussion started by: user_invalid
13 Replies
9. Shell Programming and Scripting
I'm writing my first script and I have all the other commands I'm using working properly, but I'm having one final issue with a sed. I've looked on the forums for some answers, which have been close but sed is quite confusing to me.
My problem is that I have a file called CylinderAtom1.txt... (3 Replies)
Discussion started by: 1Aegis1
3 Replies
10. Shell Programming and Scripting
Hi alll
I have a file with this content
ale,AAM,id2_1_2_1_1,23,2013-01-30,1,1
ale,BAND,id2_1_1_1_1,31,2013-01-28,1,1
ale,CAI,id2_1_1_1_1,23,2013-01-28,1,1
ale,CAI,id2_1_1_1_4,23,2013-01-28,1,1
ale,CAI,id2_1_2_1_1,23,2013-01-30,2,1
ale,NAST,id2_1_1_1_1,23,2013-01-29,1,1... (1 Reply)
Discussion started by: nikhil jain
1 Replies
LEARN ABOUT REDHAT
sttydefs
sttydefs(1M) System Administration Commands sttydefs(1M)
NAME
sttydefs - maintain line settings and hunt sequences for TTY ports
SYNOPSIS
/usr/sbin/sttydefs -a ttylabel [-b] [-f final-flags] [-i initial-flags] [-n nextlabel]
/usr/sbin/sttydefs -l [ttylabel]
/usr/sbin/sttydefs -r ttylabel
DESCRIPTION
sttydefs is an administrative command that maintains the line settings and hunt sequences for the system's TTY ports by making entries in,
and deleting entries from the /etc/ttydefs file.
sttydefs with a -a or -r option may be invoked only by the super-user. sttydefs with -l may be invoked by any user on the system.
OPTIONS
The following options are supported:
-a ttylabel Add a record to the ttydefs file, using ttylabel as its label. The following describes the effect of the -b, -n,
-i, or -f options when used in conjunction with the -a option:
-b Enable autobaud. Autobaud allows the system to set the line speed of a given TTY port to the line speed of the
device connected to the port without
the user's intervention.
-f final-flags Specify the value to be used in the final-flags field in /etc/ttydefs. final-flags must be in a format recognized
by the stty command. final-flags are the termio(7I) settings used by ttymon after receiving a successful connection
request and immediately before invoking the service on the port. If this option is not specified, sttydefs will set
final-flags equal to the termio(7I) flags 9600 and sane.
-i initial-flags Specify the value to be used in the initial-flags field in /etc/ttydefs. initial-flags must be in a format recog-
nized by the stty command. These flags are used by ttymon when searching for the correct baud rate. They are set
prior to writing the prompt. If this option is not specified, sttydefs will set initial-flags equal to the
termio(7I) flag 9600.
-n nextlabel Specify the value to be used in the nextlabel field in /etc/ttydefs. If this option is not specified, sttydefs will
set nextlabel equal to ttylabel.
-l[ttylabel] If a ttylabel is specified, sttydefs displays the record from /etc/ttydefs whose TTY label matches the specified
ttylabel. If no ttylabel is specified, sttydefs displays the entire contents of /etc/ttydefs. sttydefs verifies
that each entry it displays is correct and that the entry's nextlabel field references an existing
-r ttylabel Remove any record in the ttydefs file that has ttylabel as its label.
OUTPUT
If successful, sttydefs will exit with a status of 0. sttydefs -l will generate the requested information and send it to standard output.
EXAMPLES
Example 1: A sample of sttydefs command.
The following command lists all the entries in the ttydefs file and prints an error message for each invalid entry that is detected.
example# sttydefs -l
The following shows a command that requests information for a single label and its output:
example# sttydefs -l 9600
------------------------------------------------------------------
9600:9600 hupcl erase ^h:9600 sane ixany tab3 hupcl erase ^h::4800
------------------------------------------------------------------
ttylabel: 9600
initial flags: 9600 hupcl erase ^h
final flags: 9600 sane ixany tab3 hupcl erase ^h
autobaud: no
nextlabel: 4800
The following sequence of commands will add the labels 1200, 2400, 4800, and 9600 and put them in a circular list:
sttydefs -a 1200 -n 2400 -i 1200 -f "1200 sane"
sttydefs -a 2400 -n 4800 -i 2400 -f "2400 sane"
sttydefs -a 4800 -n 9600 -i 4800 -f "4800 sane"
sttydefs -a 9600 -n 1200 -i 9600 -f "9600 sane"
FILES
/etc/ttydefs
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
attributes(5), termio(7I)
SunOS 5.10 14 Sep 1992 sttydefs(1M)