AIX Korn shell sed -s problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AIX Korn shell sed -s problem
# 8  
Old 04-28-2009
I've found that sometimes using something other than the normal forward slashes with sed seem to work:

root@FWPAR01:/> vi jc.txt
root@FWPAR01:/> cnumb=5
root@FWPAR01:/> echo $cnumb
5
root@FWPAR01:/> sed s#flag1#$cnumb#g jc.txt
{{Company 5}}

Hope this helps.
# 9  
Old 04-28-2009
You need to do something like this:

Code:
phone=`echo $FaxFile|cut -d, -f5`
cnumb=`echo $FaxFile|cut -d, -f7`
ponum=`echo $FaxFile|cut -d, -f11`

# 10  
Old 04-28-2009
Thank you for the help.

I tried the # rather than the / in the s subcommand. It did not work, but that was a good try.

I also tried the "phone=`echo $FaxFile|cut -d, -f5`", this was not a very good attempt. the value for each variable was the name of the file, but $cnumb still ended up in the header in the place of the place holder flag1.
# 11  
Old 04-28-2009
Quote:
Originally Posted by jcarrott
Thank you for the help.

I tried the # rather than the / in the s subcommand. It did not work, but that was a good try.

I also tried the "phone=`echo $FaxFile|cut -d, -f5`", this was not a very good attempt. the value for each variable was the name of the file, but $cnumb still ended up in the header in the place of the place holder flag1.
I think you're confused by thinking that you're parsing the CONTENT of the file (FaxFile) whereas you're parsing the FILENAME itself.
Post the CONTENT of a sample FaxFile using BB codes. Also explain clearly what you want as an output.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help when using Typeset in AIX Korn Shell

Guys, please help! I am currently using an AIX server however whenever I tried to use the typeset -F3, the variable is resulting with a "#". In the given example below, I declared x to be a decimal holding 3 decimal places = 1.455. However whenever I tried to echo the $x, the resulting value... (9 Replies)
Discussion started by: zzavilz
9 Replies

2. Shell Programming and Scripting

Korn shell behaviour in AIX

Hi, Consider the code snippet below: fun() { while read x do echo $x done < somefile_that_does_not_exists } fun echo I am here Korn shell on HPUX prints the message "I am here", while the behaviour is different on AIX korn shell. We do not get the message on AIX. Any... (5 Replies)
Discussion started by: 116@434
5 Replies

3. UNIX for Dummies Questions & Answers

List of 'if -f' options - AIX / Korn Shell

Hi all, Can someone point me in the right direction for a manual on the various statement options for 'if'. Basically I have a piece of code which says: if ] and I wondered what the -f was. I know the '!' means not equal.. As usual any help much appreciated.. (5 Replies)
Discussion started by: Grueben
5 Replies

4. Shell Programming and Scripting

self-learning! my korn shell problem

i am a beginner i m learning shell by myself i have problem writing a korn shell that takes an absolute pathname to directory and display all ordinary files in the directory ordered by their length. i was thinking use grep ls sort and sed. maybe, i m wrong! can someone tell me? (2 Replies)
Discussion started by: babuda0059
2 Replies

5. Shell Programming and Scripting

korn shell automation problem!

I got the task writting Korn Shell script to automate the tuxedo login so that users neednot have to enter options manually. I have done that using expect tool from the Unix but my manger told me its not secure so you have to do that using Kornshell without using Expect. Here is the way to login to... (0 Replies)
Discussion started by: pareshan
0 Replies

6. AIX

AIX 4.2 Korn shell and grep question

Ho do I find out the verion of the Kron shell on my client`s system ? There is no one to ask. They are not knowledged enough (hard to believe but yes). Also, on that AIX 4.2, I am trying to figure out how to do a grep using a search patter like below but does not seam to work. The '*' do... (11 Replies)
Discussion started by: Browser_ice
11 Replies

7. Shell Programming and Scripting

Pattern manipulation in korn shell script using sed.

Hi, Could any one let me know, how can I cut the last field in below mentioned line. net,-hopcount,0,-netmask,255.255.255.0,,,,,192.168.37.0,10.253.0.1 net,-hopcount,0,-netmask,255.255.255.0,,,,,192.168.1.0,10.253.0.1 net,-hopcount,0,-netmask,255.255.255.0,,,,,192.168.38.0,10.253.0.1... (3 Replies)
Discussion started by: ajilesh
3 Replies

8. Shell Programming and Scripting

Problem with Korn Shell

My Korn shell script below is giving me the following error: ./test.ksh: 0403-057 syntax error at line 7 : 'then' is not matched. Can anyone provide a quick solution as to why the error is occurring? Thanks. #!/usr/bin/ksh typeset -i RecCount typeset -i RecCount2 RecCount=`db2 -x "select... (23 Replies)
Discussion started by: sasaliasim
23 Replies

9. UNIX for Dummies Questions & Answers

problem extracting substring in korn shell

hi all, I have read similiar topics in this board, but i didn' t find the posting which is the same with the problem i face.. I try to extract string from the end. i try to do this: num=abcdefghij num2=${num:-5} echo $num2 #this should print the last 5 characters (fghij) but it doesn;t... (3 Replies)
Discussion started by: nashrul
3 Replies

10. Shell Programming and Scripting

problem with set command in korn shell

I have to copy an array to a temp variable and back after doing some functions. I am trying to see if it is possible to do without while loops.My closest try was set -A temp ${THE_ARRAY} # restore array after some actions set -A THE_ARRAY ${temp} The problem with above is that, the new... (1 Reply)
Discussion started by: vijay1985
1 Replies
Login or Register to Ask a Question