Help with extracting text from a string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with extracting text from a string
# 15  
Old 02-25-2010
Sorry, yes I write the output to a text file $ACTION_LOG and i do
tail -f when I actually check in files through my IDE to see if anything is coming out.

Thanks.
# 16  
Old 02-25-2010
Just saw where you edited something previous

Can you do the following:
Code:
>echo test=A /content/qa/lesson1/index.html A /content/qa/lesson2/index.html A /content/qa/lesson3/index.html | sed 's/A/~A/g' | tr '~' '\n' | grep "^A" | cut -d" " -f2
/content/qa/lesson1/index.html
/content/qa/lesson2/index.html
/content/qa/lesson3/index.html

Essentially, do your command with a new filter at end
Code:
/usr/bin/svnlook changed $REPOS -r $REV | grep "^A.*index.html$" | sed 's/A/~A/g' | tr '~' '\n' | grep "^A" | cut -d" " -f2



---------- Post updated at 04:28 PM ---------- Previous update was at 04:25 PM ----------

append the following to your tail command
Code:
| sed 's/A/~A/g' | tr '~' '\n' | grep "^A" | cut -d" " -f2

to get one line for each instance

Does that much work?
# 17  
Old 02-25-2010
I used this and got it to work.
Code:
echo test=A /content/qa/lesson1/index.html A /content/qa/lesson2/index.html A /content/qa/lesson3/index.html | \
sed 's/A/~A/g' | tr '~' '\n' | grep "^A" | cut -d" " -f2 | cut -d"/" -f4

I get
Code:
lession1
lession2
lessions

Now I need to plug this into my actual code and see if that works as i wanted. THanks for helping me so far. i will inform you if i got this going. thanks.

Last edited by Scott; 02-25-2010 at 06:27 PM.. Reason: Code tags please...
# 18  
Old 02-25-2010
Here's another way but it's a couple milliseconds slower than sed | tr | grep | cut | cut
Code:
# echo "A /content/qa/lesson1/index.html A /content/qa/lesson2/index.html" | awk '{print $2"\n"$4}' | xargs -n1 dirname | xargs -n1 basename
lesson1
lesson2
#

# 19  
Old 02-26-2010
Question Is it working now

Unlcear whether appending the sed, etc..., commands gave you what you needed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting substring within string between 2 token within the string

Hello. First best wishes for everybody. here is the input file ("$INPUT1") contents : BASH_FUNC_message_begin_script%%=() { local -a L_ARRAY; BASH_FUNC_message_debug%%=() { local -a L_ARRAY; BASH_FUNC_message_end_script%%=() { local -a L_ARRAY; BASH_FUNC_message_error%%=() { local... (3 Replies)
Discussion started by: jcdole
3 Replies

2. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

3. Shell Programming and Scripting

Extracting text from within a section of text using AWK

I have a command which returns the below output. How can I write a script to extract mainhost and secondhost from this output and put it into an array? I may sometimes have more hosts like thirdhost. I am redirecting this output to a variable. So I guess there should be a awk or sed command to... (7 Replies)
Discussion started by: heykiran
7 Replies

4. Shell Programming and Scripting

Extracting several lines of text after a unique string

I'm attempting to write a script to identify users who have sudo access on a server. I only want to extract the ID's of the sudo users after a unique line of text. The list of sudo users goes to the EOF so I only need the script to start after the unique line of text. I already have a script to... (1 Reply)
Discussion started by: bouncer
1 Replies

5. Shell Programming and Scripting

Extracting particular string in a file and storing matched string in output file

Hi , I have input file and i want to extract below strings <msisdn xmlns="">0492001956</ msisdn> => numaber inside brackets <resCode>3000</resCode> => 3000 needs to be extracted <resMessage>Request time getBalances_PSM.c(37): d out</resMessage></ns2:getBalancesResponse> => the word... (14 Replies)
Discussion started by: sushmab82
14 Replies

6. Shell Programming and Scripting

Extracting String

I am trying to extract a hyperlink from a html document using awk. I have managed to output in the format... href="index.html"> where i would like it just to output index.html. Any ideas on how i would do this? Thanks (2 Replies)
Discussion started by: adpe
2 Replies

7. UNIX for Dummies Questions & Answers

extracting text and reusing the text to rename file

Hi, I have some ps files where I want to ectract/copy a certain number from and use that number to rename the ps file. eg: 'file.ps' contains following text: 14 (09 01 932688 0)t the text can be variable, the only fixed element is the '14 ('. The problem is that the fixed element can appear... (7 Replies)
Discussion started by: JohnDS
7 Replies

8. Shell Programming and Scripting

extracting a string

Hi All, I am writing a shell script for which I am stuck with an extraction part. I arrived till extraction of a path of file. Lets take an example. I now have a file which contains following one line: 2348/home/userid/mydir/any_num_dir/myfile.text Now I want to extract only... (2 Replies)
Discussion started by: start_shell
2 Replies

9. Shell Programming and Scripting

Extracting a string from one file and searching the same string in other files

Hi, Need to extract a string from one file and search the same in other files. Ex: I have file1 of hundred lines with no delimiters not even space. I have 3 more files. I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Discussion started by: mohancrr
1 Replies

10. Shell Programming and Scripting

extracting from a string

How do I extract 5th to 10th characters of string as given below stored in a shell variable. "ab cd ef gh ij kl" How is cut to be used on this? Thanks for any help. (1 Reply)
Discussion started by: preetikate
1 Replies
Login or Register to Ask a Question