In one part of my shell program I need to translate many of lines in the following pattern :
into strings :
the folderX/fileX is just a variable and it could be any name.
Please help me obtaining the shell script.
sample input :
desired output :
Last edited by Ghadamyari; 08-02-2012 at 08:16 AM..
For instance, in bash you can use brace expansion:
If you have stored the string in a variable, say $input, then:
So, first change the format from "/(ar|az|dua|en|fa|fr)/(index|index2).php" to "/{ar,az,dua,en,fa,fr}/{index,index2}.php". After you've checked that neither "{", "}", nor "," are present in your paths, do it this way:
Then use bash brace expansion, as shown above. For instance:
--
Bye
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)
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)
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)
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)
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)
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)
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)
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)
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)
*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)