Extract information into large variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract information into large variable
# 22  
Old 10-28-2011
Quote:
Originally Posted by WolwX
I'm sorry, I'm noob with that, can you explain me how include your command ?
Code:
perl -ne 'while(/value="(.*?)"/gi){print"$1\n" if(length$1>1)}' file.in > file.out

each line in file.in is your:

Code:
<?xml version="1.0" encoding="utf-16" standalone="yes"?> <values> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="Log" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="Admin" value="true" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="LevelName" value="blabla" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="Fastdisk1" value="" type="System.String,mscorlib" /> <add key="Fastdisk2" value="" type="System.String,mscorlib" /> <add key="Fastdisk3" value="" type="System.String,mscorlib" /> <add key="backupinterval" value="300" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="" value="true" type="System.String,mscorlib" /> <add key="backupeverything" value="false" type="System.String,mscorlib" /></values>

with value="blabla" data
tip78
# 23  
Old 10-28-2011
Quote:
Originally Posted by CarloM
What is the output of cat /home/+LOGS+/99? (Have you lost the quotes again?)
the output still the full bigvariable, including if I use single quotes, double quotes or no quotes

Code:
levelname=$(sed 's:.*<add key="LevelName" value="\([^"]*\)" type="System.String,mscorlib" />.*:\1:g' /home/+LOGS+/99)

Code:
levelname=$(sed 's:.*<add key="LevelName" value="\([^"]*\)" type="System.String,mscorlib" />.*:\1:g' '/home/+LOGS+/99')

Code:
levelname=$(sed 's:.*<add key="LevelName" value="\([^"]*\)" type="System.String,mscorlib" />.*:\1:g' "/home/+LOGS+/99")

I get the same problem when trying to call directly the bigvariable into the command, for that I want to test with bigvariable into a flat file
# 24  
Old 10-28-2011
Quotes around the filename are not what I was referring to.

Please run the command cat /home/+LOGS+/99 (at the command prompt, not in the script) and paste the output.
This User Gave Thanks to CarloM For This Post:
# 25  
Old 10-28-2011
Quote:
Originally Posted by CarloM
Quotes around the filename are not what I was referring to.

Please run the command cat /home/+LOGS+/99 (at the command prompt, not in the script) and paste the output.
Sorry :x

Here it's the output

Code:
root@blabla:/home/+LOGS+# cat 99
<?xml version="1.0" encoding="utf-16" standalone="yes"?> <values> <add key="" value="512" type="System.String,mscorlib" /> <add key="" value="512" type="System.String,mscorlib" /> <add key="JAR" value="" type="System.String,mscorlib" /> <add key="Plugins" value="plugins" type="System.String,mscorlib" /> <add key="" value="" type="System.String,mscorlib" /> <add key="Properties" value="server.properties" type="System.String,mscorlib" /> <add key="Log" value="server.log" type="System.String,mscorlib" /> <add key="MOTD" value="Powered by n1-SerVerS.fr" type="System.String,mscorlib" /> <add key="Public" value="true" type="System.String,mscorlib" /> <add key="MaxPlayer" value="10" type="System.String,mscorlib" /> <add key="MaxConnections" value="3" type="System.String,mscorlib" /> <add key="AdminSlot" value="true" type="System.String,mscorlib" /> <add key="Op1" value="" type="System.String,mscorlib" /> <add key="Op2" value="" type="System.String,mscorlib" /> <add key="Op3" value="" type="System.String,mscorlib" /> <add key="Op4" value="" type="System.String,mscorlib" /> <add key="Op5" value="" type="System.String,mscorlib" /> <add key="White1" value="" type="System.String,mscorlib" /> <add key="White2" value="" type="System.String,mscorlib" /> <add key="White3" value="" type="System.String,mscorlib" /> <add key="White4" value="" type="System.String,mscorlib" /> <add key="White5" value="" type="System.String,mscorlib" /> <add key="White6" value="" type="System.String,mscorlib" /> <add key="White7" value="" type="System.String,mscorlib" /> <add key="White8" value="" type="System.String,mscorlib" /> <add key="White9" value="" type="System.String,mscorlib" /> <add key="White10" value="" type="System.String,mscorlib" /> levelnamehere <add key="LevelSeed" value="" type="System.String,mscorlib" /> <add key="Difficulty" value="1" type="System.String,mscorlib" /> <add key="SpawnAnimals" value="true" type="System.String,mscorlib" /> <add key="GameMode" value="0" type="System.String,mscorlib" /> <add key="PrivatePassword" value="" type="System.String,mscorlib" /> </values>
root@blabla:/home/+LOGS+#

As I can see, the data including levelnamehere was removed
<add key="levelName" value="levelnamehere" type="System.String,mscorlib" />
# 26  
Old 10-28-2011
Well, that would be why the sed command doesn't find it! Smilie

EDIT: levelnamehere is actually still in your file - but untagged.
This User Gave Thanks to CarloM For This Post:
# 27  
Old 10-28-2011
Quote:
Originally Posted by CarloM
Well, that would be why the sed command doesn't find it! Smilie

EDIT: levelnamehere is actually still in your file - but untagged.
Exact !

I don't know why this was removed, but now I will test all those things ^^

Thanks again and sorry for that bug
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to extract 8 characters from a large file.

Hi All!! I have a large file containing millions of records. My purpose is to extract 8 characters immediately from the given file. 222222222|ZRF|2008.pdf|2008|01/29/2009|001|B|C|C 222222222|ZRF|2009.pdf|2009|01/29/2010|001|B|C|C 222222222|ZRF|2010.pdf|2010|01/29/2011|001|B|C|C... (5 Replies)
Discussion started by: pavand
5 Replies

2. Shell Programming and Scripting

Extract information from file

In a particular directory, there can be 1000 files like below. filename is job901.ksh #!/bin/ksh cront -x << EOJ submit file=$PRODPATH/scripts/genReport.sh maxdelay=30 &node=xnode01 tname=job901 &pfile1=/prod/mldata/data/test1.dat ... (17 Replies)
Discussion started by: vedanta
17 Replies

3. Shell Programming and Scripting

Extract information from file

Gents, If is possible please help. I have a big file (example attached) which contends exactly same value in column, but from column 2 to 6 these values are diff. I will like to compile for all records all columns like the example attached in .csv format (output.rar ).. The last column in the... (11 Replies)
Discussion started by: jiam912
11 Replies

4. UNIX for Dummies Questions & Answers

Extract spread columns from large file

Dear all, I want to extract around 300 columns from a very large file with almost 2million columns. There are no headers, but I can find out which column numbers I want. I know I can extract with the function 'cut -f2' for example just the second column but how do I do this for such a large... (1 Reply)
Discussion started by: fndijk
1 Replies

5. Shell Programming and Scripting

How to extract specific information?

hi, i have a file A like this: ******************* No 2823 ******************** contig15205- G383C4U02H4G80+ is in contig15205- G383C4U02HGLXM- is in contig15205- G383C4U01C3HIZ+ is in contig15205- ... (3 Replies)
Discussion started by: the_simpsons
3 Replies

6. Shell Programming and Scripting

How to extract information from a file?

Hi, i have a file like this: <Iteration> <Iteration_iter-num>3</Iteration_iter-num> <Iteration_query-ID>lcl|3_0</Iteration_query-ID> <Iteration_query-def>G383C4U01EQA0A length=197</Iteration_query-def> <Iteration_query-len>197</Iteration_query-len> ... (9 Replies)
Discussion started by: the_simpsons
9 Replies

7. Shell Programming and Scripting

Extract data from large file 80+ million records

Hello, I have got one file with more than 120+ million records(35 GB in size). I have to extract some relevant data from file based on some parameter and generate other output file. What will be the besat and fastest way to extract the ne file. sample file format :--... (2 Replies)
Discussion started by: learner16s
2 Replies

8. Shell Programming and Scripting

Extract large list of substrings

I have a very long string (millions of characters). I have a file with start location and length that is thousands of rows long: Start Length 5 10 16 21 44 100 215 37 ... I'd like to extract the substring that corresponds to the start and length from each row of the list: I tried... (7 Replies)
Discussion started by: dcfargo
7 Replies

9. Shell Programming and Scripting

AWK to extract information

Hi all, I am working on a shell script to extract information from a file that has output from Oracle sqlplus. The problem is that the output of a single line is spread across multiple lines and i do not know as how to extract the particular filed at ones,which spans multiple lines.... (2 Replies)
Discussion started by: harris2107
2 Replies

10. Shell Programming and Scripting

How do you extract the information from a library?

hi all, i am quite new with Perl (just 1 week of experience) and i am suppose to understand the usage of library, which i can't, anyway... i came across this library...i think from the linux redhat redhat.linux.lib.pl, there are a couple of functions there that can be used to retrieve information... (3 Replies)
Discussion started by: mercz
3 Replies
Login or Register to Ask a Question