Extracting String from a list


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting String from a list
# 1  
Old 05-29-2002
Extracting String from a list

I have a string of Data such as

Date Time Tran1 Tran2 Tran3 ......

How can I extract just all the trans excluding Date and Time.

Thanks,

Odogbolu98
Smilie
# 2  
Old 05-29-2002
awk

you can extract the tran by using awk command

pipe the list through awk, example

ls -l | awk '{print $3" "$4" "$5}'

or if the string of data is in a file you could cat the file
eg

cat filename | awk '{print $3" "$4" "$5}'


this will get Tran1 on colume 3, Tran2 on colume 4, & tran3 on colume 5.

Last edited by hassan2; 05-29-2002 at 04:35 PM..
# 3  
Old 05-29-2002
Thanks Hassan, But the problem is that there are different numbers of trans involved. That is why I used continuation sign(...) There could be as many as 4 to 7 or even 1 trans. I would need a strict to extract the trans, irrespective of the number of trans involved.

Hope this explans the situation.

Odogbolu98
# 4  
Old 05-30-2002
Try using the shell:
Code:
while read junk1 junk2 good_stuff
do
echo "$good_stuff"
done < your_file

# 5  
Old 06-01-2002
Re: Extracting String from a list

Hi,

How about using

echo $line|tr -s " "|cut -d" " -f 3-


hope this solves the issue


rgds
penguin
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. Shell Programming and Scripting

Extracting the part of string

I have a string: 2015-04-16 07:30:05,625000 +0900 xxxx.com I just want to extract the time from the above line I am using the below syntax x=~ /(.*) (\d+)\:(\d+)\:(\d+),(.*)\.com/ $time = $2 . ':' . $3 . ':' . $4; print $time But it is not working. Can some1 please help (2 Replies)
Discussion started by: karan8810
2 Replies

3. Shell Programming and Scripting

Extracting Details from string -- Help Me!!!

Hi Experts, I am executing a script in bash profile and having file path as follows: $FilePath=$HOST_NAME_LAND/home/chandan/abc.txt where $HOST_NAME_LAND is an environment variable which points to the server name. export $HOST_NAME_LAND=//<server name> The environment variable name and... (6 Replies)
Discussion started by: ChandanN
6 Replies

4. 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

5. Shell Programming and Scripting

Extracting numbers from a string

Hello Everyone, i have quick question. I have file names like: bin_map300.asc and I would like to extract grid300. My approach so far: name=bin_map300.asc echo ${name%%.*} echo ${name##*_} I am stuck combining the two. Any help would be appreciated. (3 Replies)
Discussion started by: creamcheese
3 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. 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

8. 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

9. Shell Programming and Scripting

Extracting part of a string

Hi all, I have to extract only the second part of a database column (VARCHAR) and the value is seperated by a "~" xyz~ chxyz36r~ abder~000082685 mnops~000083554 fulfil302~00026 Above are some examples of the values and for each record I have to extract the value after "~" , if there is a... (8 Replies)
Discussion started by: sam_78_nyc
8 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