SED capturing information from a variable


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers SED capturing information from a variable
# 1  
Old 10-03-2012
SED capturing information from a variable

Hi

I can't get this line to work. I need to capture what is between Home and plugin_out, where the .* is located.
Code:
RUN=`echo '${TSP_FILEPATH_PLUGIN_DIR}' | sed -e 's^/results/analysis/output/Home/\(.*\)/plugin_out/g'`;
echo ${RUN};

I'm getting the error
sed: -e expression #1, char 51: unterminated `s' command
# 2  
Old 10-03-2012
Code:
sed -e 's#.*/Home/\(.*\)/plugin_out/.*#\1#g'

NOTE: .* is greedy. It will capture from first "/Home/" to last "/plugin_out/", so the g (global) is useless in this case.

Last edited by rdrtx1; 10-03-2012 at 01:36 PM..
This User Gave Thanks to rdrtx1 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[SOLVED] Capturing output in a korn variable

Hi, I'm new to korn and having trouble capturing the text output from one program in an array that I can then feed into another program. Direct approaches didn't work, so I've tried to break it down thus: The program lonlat2pixline gives the values I need in the second column, so I print that... (4 Replies)
Discussion started by: daurin
4 Replies

2. Shell Programming and Scripting

capturing the value in file before string(*) using sed

I am trying to capture the last value before the the * in test4.txt file using sed & tail (in this case 0FA). I got the output using the below steps. P.s: The number of * in the file varies from file to file. Any idea of a better way to do this? cat test4.txt ... (2 Replies)
Discussion started by: sai_1712
2 Replies

3. Shell Programming and Scripting

Help with capturing homedir via ssh and saving to variable

I need to capture the homedir using the ssh command and then saving it to a variable. The results from the following command is what I need to capture to a variable: NOTE: the value I'm getting back is also incorrect. as it seems to be getting the home dir from the local server and not the... (2 Replies)
Discussion started by: reneuend
2 Replies

4. Shell Programming and Scripting

capturing a file to store in a variable

I have a file in a windows directory the file is delivery to us like this 07210900.dat where 07210900 is the current date. If I want to store that file in a variable UpLoadFileName and rename, so I can Ftp later to a UNIX directory, I am doing this, is this correct? CDRemoteDir='cd... (0 Replies)
Discussion started by: rechever
0 Replies

5. UNIX for Dummies Questions & Answers

Capturing a value in to variable.

Hi, I currently have a shell script where it captures in the value in to 'TOTAL' and outputs to a file, i want to capture another value of a query in to another variable and output it. Current script: sqlplus -s $user <<EOD | read TOTAL set heading off set pages 0 set feedback off set... (1 Reply)
Discussion started by: ravi0435
1 Replies

6. Shell Programming and Scripting

Losing new lines when capturing output to variable

Explain this? $ ls | grep -e "crd\|cs" crd cs $ CLONES=`ls | grep -e "crd\|cs"`;echo $CLONES; crd cs $ CLONES=`ls | grep -e "crd\|cs"`;echo "$CLONES"; crd cs (1 Reply)
Discussion started by: blasto333
1 Replies

7. Shell Programming and Scripting

capturing the o/p to a variable

Hi, #Script mentioned below txt=($(echo `./demo1.sh`)) p=0 for p in "$txt" do col=($(./generateTable /import/data01/sri/Developer/SqlReport/Lab/23/${var} "$p")) . . . . done o/p displayed upon executing a script called "demo1.sh" is as below(two seperate lines):... (2 Replies)
Discussion started by: villain41
2 Replies

8. UNIX for Dummies Questions & Answers

Capturing some data from a file into a variable

I have a file with some values in a tab delimted format Eg: 'test' contains: a<tab>b<tab>c<tab>Trk_12345678 now i need to capture this value 'Trk_12345678' into a variable say 'x' and append that value of 12345678 to 12345679 and store is back to a new 'test1' file as : 'test1'... (11 Replies)
Discussion started by: shiroh_1982
11 Replies

9. Shell Programming and Scripting

Capturing value into variable

Hi, I am new to shell scripting, I am trying to write a shell script, which will automate the process of mailing the invoices at the end of the day. For major part I am using Oracle database function. The problem is I want to capture the value returned by the Oracle function into the script... (2 Replies)
Discussion started by: prasad01
2 Replies

10. UNIX for Dummies Questions & Answers

capturing the output of grep as integer variable

Hi, I have an expression using grep and nawk that captures the ID number of a given Unix process. It gets printed to screen but I don't know how to declare a variable to this returned value! For example, ps -ef|grep $project | grep -v grep | nawk '{print $2}' This returns my number. How... (2 Replies)
Discussion started by: babariba
2 Replies
Login or Register to Ask a Question