...
I need to extract the "0.246E+05" value from the first file (File1)
I then need to input this value into a newly created file with some other stuff.
For example file two should read:
Code:
Blah blah random text
random $text that has $$variables in it but I need to just be text
the above line should literally read "$text" and "$variables"
other $random text that i $need to evaluate variables
the above line should convert $random and $need to their respective values example 5 and 51
The variable $extracted_number - this number needs to be 0.246E+05
I don't quite understand the program in your first post, but the following Perl program might be able to help you out -
Code:
$
$
$ # Show the content of the file "file1". We'll make use of the fact that "CVR(10)" and "SAUCE"
$ # appear only once in the file.
$
$ cat file1
CVR( 9) = 0.385E+05, ! VEHICLE
CVR(10) = 0.246E+05, ! SAUCE
CVR(11) = 0.162E+03, ! VEHICLE
$
$
$ # Show the Perl program
$
$ cat -n file1.pl
1 #!perl -w
2 use strict;
3
4 my $random = 5;
5 my $need = 51;
6 my $extracted_number;
7 my $file = "file1";
8
9 # read the value of $extracted_number from "file1"
10 open (FH, "<", $file) or die "Can't open $file for reading: $!";
11 while (<FH>) {
12 if (/^CVR\(10\)\s*=\s*(.*?),.*?SAUCE$/) {
13 $extracted_number = $1;
14 last;
15 }
16 }
17 close (FH) or die "Can't close $file: $!";
18
19 # We have read the value of $extracted_number now; it will be used
20 # while printing the string below
21 my $str = <<"EOF";
22 Blah blah random text
23 random \$text that has \$\$variables in it but I need to just be text
24 the above line should literally read "\$text" and "\$variables"
25 other $random text that i $need to evaluate variables
26 the above line should convert \$random and \$need to their respective values example 5 and 51
27 The variable $extracted_number - this number needs to be 0.246E+05
28 EOF
29
30 print $str;
$
$
$ # Execute the Perl program
$
$ perl file1.pl
Blah blah random text
random $text that has $$variables in it but I need to just be text
the above line should literally read "$text" and "$variables"
other 5 text that i 51 to evaluate variables
the above line should convert $random and $need to their respective values example 5 and 51
The variable 0.246E+05 - this number needs to be 0.246E+05
$
$
$
tyler_durden
This User Gave Thanks to durden_tyler For This Post:
Hi,
This is the first time playing around with perl and need some help.
Assuming if i have a line of text that looks like this:
Date/Time=Nov 18 17:12:11;Device Name=192.168.1.1;Device IP=192.168.1.1;Device Class=IDS;Source IP=155.212.212.111;Source Name=UNKNOWN;Source Port=1679... (3 Replies)
Hi All,
I am having an XML tag like:
<detail sim_ser_no_1="898407109001000090"
imsi_1="452070001000090">
<security>ADM1=????</security>
<security>PIN1=????</security>
<security>PIN2=????</security>
... (2 Replies)
Hello fourm members,
I want to write a script to extarct paticular strings from the all type of files(.sh files,logfiles,txtfiles) and redirect into a log file.
example:
I have to find the line below in the script and extract the uname and Pwds.
sqsh -scia2007 -DD0011uw01 -uciadev... (5 Replies)
Dear all,
I am trying to extract a number from a line in one file (task 1), duplicate another file (task 2) and replace all instances of the strings 300, in duplicated with the extracted number (task 3). Here is what I have tried so far:
for ((k=1;k<4;k++)); do
temp=`sed -n "${k}p"... (2 Replies)
dear all,
i need your advice
i have sample script like this:
testing.sh
for i in {1..10}
do
echo testing $i
done
but i forgot create "#!/bin/bash" in above "for"
so i want output will like this
testing.sh
#!/bin/bash
for i in {1..10}
do
echo testing $i
done (2 Replies)
i'm trying to write a bash script that that will automatically extract zip files after the download.
i writed this script
#!/bin/bash
wget -c https://github.com/RonGokhle/kernel-downloader/zipball/master
CURRENDIR=/home/kernel-downloader
cd $CURRENDIR
rm $CURRENDIR/zipfiles 2>/dev/null
... (2 Replies)
Hi friend i have input as following XML file
<?xml version="1.0"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.02">
<BkToCstmrDbtCdtNtfctn>
<GrpHdr><MsgId>LBP-RDJ-TE000000-130042430010001001</MsgId><CreDtTm>2013-01-04T03:21:30</CreDtTm></GrpHdr>... (3 Replies)
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)
I have file which contains a huge amount of data. I need to search the pattern Message id. When that pattern is matched I need to get abcdeff0-1g6g-91g3-1z2z-2mm605m90000 to another file.
Kindly provide your input.
File is like below
Jan 11 04:05:10 linux100 |NOTICE... (2 Replies)