Sponsored Content
Top Forums Shell Programming and Scripting Extract specific text from variable and put it into array Post 302698087 by elixir_sinari on Saturday 8th of September 2012 02:34:51 AM
Old 09-08-2012
Code:
line='1234[12345678=3]; 54321[98765432=3]; 1234[57382939=3]; 8888[984903020=3]; 77777[0583758738=3]; 8888[670986767=3]'
arr=($(echo "$line"|awk -F\; '{for(i=1;i<=NF;i++) if(!c[$i+0]++) print $i+0}'))
for i in "${arr[@]}"
do
 echo "I AM " $i
done


Last edited by elixir_sinari; 09-08-2012 at 04:19 AM..
This User Gave Thanks to elixir_sinari For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extract some specific text file urgent pls

i have a big text file . i want to create new file as extract some specific text from the big file i am using hp ux please help (2 Replies)
Discussion started by: reyazan
2 Replies

2. Shell Programming and Scripting

extract the lines between specific line number from a text file

Hi I want to extract certain text between two line numbers like 23234234324 and 54446655567567 How do I do this with a simple sed or awk command? Thank you. ---------- Post updated at 06:16 PM ---------- Previous update was at 05:55 PM ---------- found it: sed -n '#1,#2p'... (1 Reply)
Discussion started by: return_user
1 Replies

3. Shell Programming and Scripting

Extract lines of text based on a specific keyword

I regularly extract lines of text from files based on the presence of a particular keyword; I place the extracted lines into another text file. This takes about 2 hours to complete using the "sort" command then Kate's find & highlight facility. I've been reading the forum & googling and can find... (4 Replies)
Discussion started by: DionDeVille
4 Replies

4. UNIX for Advanced & Expert Users

bash/grep/awk/sed: How to extract every appearance of text between two specific strings

I have a text wich looks like this: clid=2 cid=6 client_database_id=35 client_nickname=Peter client_type=0|clid=3 cid=22 client_database_id=57 client_nickname=Paul client_type=0|clid=5 cid=22 client_database_id=7 client_nickname=Mary client_type=0|clid=6 cid=22 client_database_id=6... (3 Replies)
Discussion started by: Pioneer1976
3 Replies

5. Shell Programming and Scripting

Put output into an array

I'm trying to take the output of an environment that has multiple strings ex. # echo $SSH_CLIENT 192.168.1.1 57039 22 I need that IP... so I can set it to another environment. Thank you (3 Replies)
Discussion started by: adelsin
3 Replies

6. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

7. Shell Programming and Scripting

Shell script to put delimiter for a no delimiter variable length text file

Hi, I have a No Delimiter variable length text file with following schema - Column Name Data length Firstname 5 Lastname 5 age 3 phoneno1 10 phoneno2 10 phoneno3 10 sample data - ... (16 Replies)
Discussion started by: Gaurav Martha
16 Replies

8. Shell Programming and Scripting

Extract text from file then write variable

I have a text file that has many lines, and for each line I need to extract different sections of text, then write several variables from the data. I can split out the various sections by selecting their position on each line as the column sizes will never vary. A sample of my text file is below... (2 Replies)
Discussion started by: kcpoole
2 Replies

9. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

10. Shell Programming and Scripting

Passing specific and incrementing lines of text from file via variable

This is part of a larger script where I need to pass only 1 line of a file to the script, based on a variable and not a direct reference. As part of a for loop : # for((line=0;line<50;line++)); do # awk ‘NR==$line' PhraseList.txt; done ... (5 Replies)
Discussion started by: Seth
5 Replies
DATEFMT_LOCALTIME(3)							 1						      DATEFMT_LOCALTIME(3)

IntlDateFormatter::localtime - Parse string to a field-based time value

	Object oriented style

SYNOPSIS
public array IntlDateFormatter::localtime (string $value, [int &$position]) DESCRIPTION
Procedural style array datefmt_localtime (IntlDateFormatter $fmt, string $value, [int &$position]) Converts string $value to a field-based time value ( an array of various fields), starting at $parse_pos and consuming as much of the input value as possible. PARAMETERS
o $fmt - The formatter resource o $value - string to convert to a time o $position - Position at which to start the parsing in $value (zero-based). If no error occurs before $value is consumed, $parse_pos will contain -1 otherwise it will contain the position at which parsing ended . If $parse_pos > strlen($value), the parse fails immedi- ately. RETURN VALUES
Localtime compatible array of integers : contains 24 hour clock value in tm_hour field EXAMPLES
Example #1 datefmt_localtime(3) example <?php $fmt = datefmt_create( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); $arr = datefmt_localtime($fmt, 'Wednesday, December 31, 1969 4:00:00 PM PT', 0); echo 'First parsed output is '; if ($arr) { foreach ($arr as $key => $value) { echo "$key : $value , "; } } ?> Example #2 OO example <?php $fmt = new IntlDateFormatter( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); $arr = $fmt->localtime('Wednesday, December 31, 1969 4:00:00 PM PT', 0); echo 'First parsed output is '; if ($arr) { foreach ($arr as $key => $value) { echo "$key : $value , "; } } ?> The above example will output: First parsed output is tm_sec : 0 , tm_min : 0 , tm_hour : 16 , tm_year : 1969 , tm_mday : 31 , tm_wday : 4 , tm_yday : 365 , tm_mon : 11 , tm_isdst : 0 , SEE ALSO
datefmt_create(3), datefmt_format(3), datefmt_parse(3), datefmt_get_error_code(3), datefmt_get_error_message(3). PHP Documentation Group DATEFMT_LOCALTIME(3)
All times are GMT -4. The time now is 06:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy