Sponsored Content
Top Forums Shell Programming and Scripting Convert .../($var1|$var2)/... regex to string Post 302680639 by Ghadamyari on Thursday 2nd of August 2012 06:46:09 AM
Old 08-02-2012
Java Convert .../($var1|$var2)/... regex to string

Hello,

In one part of my shell program I need to translate many of lines in the following pattern :
Code:
/(folder1|...|folderN)/(sub1|...|subN)/.../(file1|...|fileN)

into strings :
Code:
/folder1/sub1/.../file1
/folder1/sub1/.../...
/folder1/sub1/.../fileN
...
/folderN/subN/.../fileN

the folderX/fileX is just a variable and it could be any name.

Please help me obtaining the shell script.

sample input :
Code:
/(ar|az|dua|en|fa|fr)/(index|index2).php
/(ar|az|dua|en|fa|fr)/administrator/(index|index2).php
/(ar|fa)/modules/(mod_tabmods|mod_tabs|mod_base|mod_secure)/scripts/(importer|uploader).php

desired output :
Code:
/ar/index.php
/ar/index2.php
/az/index.php
/az/index2.php
/dua/index.php
/dua/index2.php
/en/index.php
/en/index2.php
/fa/index.php
/fa/index2.php
/fr/index.php
/fr/index2.php
/ar/administrator/index.php
/ar/administrator/index2.php
/az/administrator/index.php
/az/administrator/index2.php
/dua/administrator/index.php
/dua/administrator/index2.php
/en/administrator/index.php
/en/administrator/index2.php
/fa/administrator/index.php
/fa/administrator/index2.php
/fr/administrator/index.php
/fr/administrator/index2.php
/ar/modules/mod_tabmods/scripts/importer.php
/ar/modules/mod_tabmods/scripts/uploader.php
/ar/modules/mod_tabs/scripts/importer.php
/ar/modules/mod_tabs/scripts/uploader.php
/ar/modules/mod_base/scripts/importer.php
/ar/modules/mod_base/scripts/uploader.php
/ar/modules/mod_secure/scripts/importer.php
/ar/modules/mod_secure/scripts/uploader.php
/fa/modules/mod_tabmods/scripts/importer.php
/fa/modules/mod_tabmods/scripts/uploader.php
/fa/modules/mod_tabs/scripts/importer.php
/fa/modules/mod_tabs/scripts/uploader.php
/fa/modules/mod_base/scripts/importer.php
/fa/modules/mod_base/scripts/uploader.php
/fa/modules/mod_secure/scripts/importer.php
/fa/modules/mod_secure/scripts/uploader.php


Last edited by Ghadamyari; 08-02-2012 at 08:16 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

*fixed if (( var1 && var2 )) ??

*EDIT -- **FIXEd I must've done something wrong, because it works now.. I punched in "if" in the forum search but nothing came up, so I'm posting it here. Quick question: Can someone correct my syntax. #!/bin/ksh if (( var >= 1 && var <= 5 )); then .................................. (1 Reply)
Discussion started by: yongho
1 Replies

2. Shell Programming and Scripting

Echo var1,var2,var3,var4,var5,var6 in loop help

Hello, I have created numerous variables called $mask1 $mask2... $maskN. I wish to echo these variables, below is the code for the two functions, the first creates the variables and the second echos them. It is the second function which does not work. The line (i believe to be wrong) is in... (1 Reply)
Discussion started by: rorey_breaker
1 Replies

3. Shell Programming and Scripting

(probably stupidly simple) if [ $var1 = $var2 ] problem...

OK, while I'm not new to the Mac or some of the the inner workings of Mac OS X I am quite new to scripting. And while I have "Learning the Bash Shell" by those lovely people at O'Reilly (Cameron Newham et. al.) I'm missing something, I just know I am. Here's the problem: At the beginning of... (2 Replies)
Discussion started by: woodgie
2 Replies

4. UNIX for Dummies Questions & Answers

regex on first string in a variable.

Hi all, this is driving me nuts. I need to evaluate if a variable in a shell script has a heading s or m character e.g. s92342394 or m9233489 if so then I need to get rid of them. I'm quite familiar with PERL and could do it there in 3 mins but I have not found a decent way to do this in a shell.... (1 Reply)
Discussion started by: Endo
1 Replies

5. UNIX for Dummies Questions & Answers

What is this? var2=${var1#??????????}

Googling the answer to this question just doesn't work when Google won't search your symbols for you. Can someone tell me what this command will assign to var2, and where I can find more information about using braces in this way? var2=${var1#??????????} Thanks so much. (2 Replies)
Discussion started by: blondie53403
2 Replies

6. Shell Programming and Scripting

using regex to get part of a string ?

Hi there, i wonder, is it possible to use regular expressions to partially select a string? I have a bunch of server names which look like this server1z-test server2z2 server45z-primary server13z3 I want to extract up to and including the 'z' in the server name, so for example ... (4 Replies)
Discussion started by: hcclnoodles
4 Replies

7. Shell Programming and Scripting

BASH regex (convert from working perl version)

Hi there, I need to test that a variable ($VAR) matches a regex mask in BASH. I have the exact thing working in perl (below), but could somebody advise me how i would do the same in BASH ? do i need to use something like egrep ? #!/bin/perl -w my $VAR = "some value"; if ( $VAR =~... (4 Replies)
Discussion started by: rethink
4 Replies

8. Shell Programming and Scripting

concatenate varaibles var1, var2 together to var1 again

HI i like to concatenate the two variables var1=$line (ie 22885068900000652 B86860003OLFXXX592123320081227) var2=$amount (ie 123456) i want to club together both the above varaible var1 & var2 and assign back to var1 right now i am doing like this but it is not working. var1=`echo... (1 Reply)
Discussion started by: kshuser
1 Replies

9. Shell Programming and Scripting

filtering out duplicate substrings, regex string from a string

My input contains a single word lines. From each line data.txt prjtestBlaBlatestBlaBla prjthisBlaBlathisBlaBla prjthatBlaBladpthatBlaBla prjgoodBlaBladpgoodBlaBla prjgood1BlaBla123dpgood1BlaBla123 Desired output --> data_out.txt prjtestBlaBla prjthisBlaBla... (8 Replies)
Discussion started by: kchinnam
8 Replies

10. Shell Programming and Scripting

Convert posix regex to pcre (perl)

In order to clean file from html tags i used the following sed 's/<*>//g' filename Right now i need to do the same from php script so i have to use pcre. How to convert? (1 Reply)
Discussion started by: urello
1 Replies
php-config(1)							Scripting Language						     php-config(1)

NAME
php-config - get information about PHP configuration and compile options SYNOPSIS
php-config [options] DESCRIPTION
php-config is a simple shell script for obtaining information about installed PHP configuration. OPTIONS
--prefix Directory prefix where PHP is installed, e.g. /usr/local --includes List of -I options with all include files --ldflags LD Flags which PHP was compiled with --libs Extra libraries which PHP was compiled with --man-dir The directory prefix where the manpages is installed --extension-dir Directory where extensions are searched by default --include-dir Directory prefix where header files are installed by default --php-binary Full path to php CLI or CGI binary --php-sapis Show all SAPI modules available --configure-options Configure options to recreate configuration of current PHP installation --version PHP version --vernum PHP version as integer SEE ALSO php(1) VERSION INFORMATION
This manpage describes php, version 5.4.16. COPYRIGHT
Copyright (C) 1997-2010 The PHP Group This source file is subject to version 3.01 of the PHP license, that is bundled with this package in the file LICENSE, and is available through the world-wide-web at the following url: http://www.php.net/license/3_01.txt If you did not receive a copy of the PHP license and are unable to obtain it through the world-wide-web, please send a note to license@php.net so we can mail you a copy immediately. The PHP Group 2010 php-config(1)
All times are GMT -4. The time now is 05:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy