Pattern Matching and extracting the required fields in Perl
Hi All,
I am writing the following Perl Scrip and need your help in Pattern matching :
I have the following Shell Script that would read line by line from the file (file_svn) and would inturn calls the Perl Script:
Code:
#!/bin/bash
perl_path="/home/dev/filter"
version_file_path="/home/dev/filter"
version_file="file_svn"
perl_file="SVN_Extract_Script_1.pl"
while read line
do
echo "Printing $line"
$perl_path/$perl_file -v $line --> Included options -v , actually not necessary
done < "/home/dev/filter/file_svn"
The file file_svn contains the following:
Code:
https://ims-svnus.com/dev/DB/trunk/feeds/templates/shell_script.txt -r860
https://ims-svnus.com/dev/DB/trunk/db/sec_db/stored_procedures/alter.sql -r990
https://ims-svnus.com/dev/DB/trunk/com/bin/aim/filter.java -r456
..so on
From the above,
1) Get the path after trunk and then create those directories under the /home/dev/filter/build/tmpl/ and /home/dev/filter/build/ovrd/ if they dont exists.
(excluding -r860 ..etc)
Example:
After Running the Perl Script for first line:
The directories (/feeds/templates/) doesn't exists under /home/dev/filter/build/tmpl/ and /home/dev/filter/build/ovrd/ , then we have to create them.
Then the file should be saved as
/home/dev/filter/build/tmpl/feeds/templates/shell_script.txt
Fyi -> svn export (firstline) <<path>> would actually saves the file under the given path.
The Perl Script is below:
Code:
#!/usr/bin/perl
use Getopt::Std;
getopts('v:', %opts) || die "Invalid options passed\n"; --> not sure why this is not working
$ver=$opts{"v"};
$build_home="/home/dev/filter/build/";
$root_dir="/home/dev/filter/";
$vob_dir="https://ims-svnus.com/dev/DB/trunk/";
$dest_tmpl_path="/home/dev/filter/build/tmpl/";
$dest_ovrd_path="/home/dev/filter/build/ovrd/";
unless ( $ver =~ /\.java$/ ) -- If the line contains other than .java
{
($full_path, $version) = split(' ',$ver);
$temp = reverse $full_path;
($file) = split(/\//, $temp);
$file = reverse $file;
$full_path =~ /^${vob_dir}(.*)${file}$/;
$full_path = $1;
$full_path =~ s/templates\///;
$dest_tmpl_path .= "$full_path";
$dest_ovrd_path .= "$full_path";
`mkdir -p $dest_tmpl_path` if (! -e $dest_tmpl_path );
`mkdir -p $dest_ovrd_path` if (! -e $dest_ovrd_path );
`svn export $ver $dest_tmpl_path$file`; --> $file should contain the entire path after trunk including the filename
<<<< I will perform someother things here >>>>
}
IF << .java>>> in theline
then
Perform the same things as above
But << I will not performthe other things that I am doing in above step >>>
END
Could someone please help me out in finishing the above perl script.
https://ims-svnus.com/dev/DB/trunk/feeds/templates/shell_script.txt -r860
https://ims-svnus.com/dev/DB/trunk/db/sec_db/stored_procedures/alter.sql -r990
https://ims-svnus.com/dev/DB/trunk/com/bin/aim/filter.java -r456
..so on
From the above,
1) Get the path after trunk and then create those directories under the /home/dev/filter/build/tmpl/ and /home/dev/filter/build/ovrd/ if they dont exists.
(excluding -r860 ..etc)
Example:
After Running the Perl Script for first line:
Hi I am trying to pattern match with sed, if it finds a match I need it to insert characters at the 28th position, its working but its also adding an extra space and I don't know why, below is the code.
sed 's/715023044/\n&/g' $asn | sed '/^71502304413-000/s/./B4/28' | sed -e :a -e... (4 Replies)
Hi,
I have a string looks like the following:
USERS 32767.9844 UNDOTBS1 32767.9844 SYSAUX 32767.9844 SYSTEM 32767.9844 EMS 8192 EMS 8192 EMS_INDEXES 4096 EMS_INDEXES 4096 8 rows selected.
How do I extract a sub-string to get the expected output as following:
EMS 8192
EMS_INDEXES 4096
... (3 Replies)
Guys, i'm new to shell scripting. Here's what i need.
I need a shell script which would read a file containing only 1 line which never changes.
File containts -
SQL_Mgd_Svc_ELONMCL54496 |EMEA\brookkev, EMEA\fieldgra, EMEA\tidmamar, EMEA\attfiste, EMEA\baldogar, EMEA\clarkia2, EMEA\conwasha,... (9 Replies)
Hi All,
I am pretty new to pattern matching and extraction using shell scripting. Could anyone please help me in extracting the word matching a pattern from a line in bash.
Input Sample (can vary between any of the 3 samples below):
1) Adaptec SCSI RAID 5445
2) Adaptec SCSI 5445S RAID
3)... (8 Replies)
Hi All ,
I need to extract the strings that are matching with the pattern : CUST.<AnyStringOfAnyLength>.<AnyStringOfAnyLength> from a file and then write all these string into another file.
e.g. If a file SOURCE contains following lines :
IF(CUST.ABCD.EFGH==1) THEN
CUST.ABCD.EFGH =... (7 Replies)
Hello experts,
I have a file containing the following text(shortened here).
File Begin
----------
< # Billboard.d3fc1302a677.imagePath=S:\\efcm_T4
< Billboard.d3fc1302a677.imagePath=S:\\efcm_T4
---
> # Billboard.d3fc1302a677.imagePath=S:\\efcm_Cassini
>... (2 Replies)
Hi there,
i'm having some problems just making an awk script (i've tried this way, but other way can be posible for sure), for the next file
file.txt
<register>
<createProfile>
<result>0</result>
<description><!]></description>
<msisdn>34661461174</msisdn>
<inputOmvID>1</inputOmvID>... (6 Replies)
Hello everyone, this is my first post so please give me a hand.
I apologize for my English, I'll try to be clear with my request.
I need to write a script (Bash) which finds all the variables defined in the file .h of the folder and then writes the name of the files .c where these variables are... (1 Reply)
Hi all, how could i do ?
I have a Rss file, i want to extract only the Urls (many) matching http://www.xxx.com/trailers/ from that file and copy into another file.
like
"
<pubDate>Wed, 29 Apr 2009 00:00:00 PST</pubDate>
<content:encoded><!Apple - Movie Trailers - The Hangover"><img... (3 Replies)
hi i am trying to get digits inside brackes from file , whose structure is defined below
CREATE TABLE TELM
(SOC_NO CHAR (3) NOT NULL,
TXN_AMOUNT NUMBER (17,3)
SIGN_ON_TIME CHAR (8)
TELLER_APP_LIMIT NUMBER (17,3)
FIL01 ... (2 Replies)