I need help on phrasing the correct regular expression or shell script
for the following :
url=/xxx/yyy/zzz/a.jsp /xxx/yyy/zzz/b.jsp /xxx/yyy/zzz/c.jsp /xxx/yyy/aaa/d.jsp
Now, when i try to output the value of variable "url" into a file it
goes as one line like the following :
==========================================================================
/xxx/yyy/zzz/a.jsp /xxx/yyy/zzz/b.jsp /xxx/yyy/zzz/c.jsp /xxx/yyy/aaa/d.jsp
===========================================================================
I need it to go like
/xxx/yyy/zzz/a.jsp
/xxx/yyy/zzz/b.jsp
/xxx/yyy/zzz/c.jsp
/xxx/yyy/aaa/d.jsp
basically one JSP on each line.
I can use Perl, sh, sed awk for this work. |
Request for Question Clarification by
mathtalk-ga
on
05 Jan 2004 13:45 PST
Hi, cheekoo1-ga:
If the line breaks are actually stored in shell variable url, then you
may not be seeing them because of the Unix shell removing whitespace
(spaces, tabs, newlines) from the string before doing the substitution
(leaving only a single space as a delimiter). This is generally what
one wants in constructing command line arguments.
To preserve the whitespace (and in particular any embedded line
breaks) enclose the value of the script variable in double quotes,
like this:
"$url"
when you use it. Give it a try, e.g. with an echo command, and see if
that makes the difference you want.
regards, mathtalk-ga
|
Clarification of Question by
cheekoo1-ga
on
05 Jan 2004 14:21 PST
Hi Mathtalk:ga,
Thanks for your suggestion, but that did not seem to fix it.Let
me give u some more context. I have a makefile like the following :
===============================================================================
JSP_LONGDIR=/opt/www/options
# Only include files here that are root JSPs (compilable ones)
FILES+=$(JSP_LONGDIR)/profileList.jsp
FILES+=$(JSP_LONGDIR)/profileListSubmit.jsp
FILES+=$(JSP_LONGDIR)/editProfileName.jsp
all: local
local:
@$(SH) /opt/bin/JspLister.sh $(FILES) || exit 1;
=============================================================================
The JspCompiler.sh file now contains somethihng like the following :
urls="$*"
urls=`echo $urls | perl -pe 's{[^ ]+/www/}{/}g'`
if [ ! -z "$ANT_BUILD" ]
then
echo -e "ANT_BUILD variable is set ."
{
echo "$urls"
} >> "op.test" # Redirects output of everything in block to file.
exit
fi
=================================================
if I look inside the "op.test" output file , the listing that I get
contains one seperate line for each makefile that is used.But that one
line may or may not contain multiple JSP listings.
That is the problem that I am trying to solve.
eg : The following needs to be changed FROM
/index.jsp
/ac/index.jsp
/ANZ/admin/managers.jsp /ANZ/admin/messaging.jsp
/ANZ/admin/purview.jsp /ANZ/admin/purviewmessaging.jsp
to
/index.jsp
/ac/index.jsp
/ANZ/admin/managers.jsp
/ANZ/admin/messaging.jsp
/ANZ/admin/purview.jsp
/ANZ/admin/purviewmessaging.jsp
|
Clarification of Question by
cheekoo1-ga
on
05 Jan 2004 14:23 PST
Sorry for the typo ...
please read
The JspCompiler.sh file now contains somethihng like the following : as
The JspLister.sh file now contains somethihng like the following :
|
Request for Question Clarification by
maniac-ga
on
05 Jan 2004 18:29 PST
Hello Cheekoo1,
I am not sure which shell you are using, I'll assume sh (and not csh).
Have you tried something like...
#!/bin/sh
if [ ! -z "$ANT_BUILD" ]
then
echo -e "ANT_BUILD variable is set ."
else
for N in $* ; do
echo "$N" >> "op.test"
done
fi
which will append the arguments, one per line, to the op.test file. If
this meets your needs, I'll post this (and an explanation) as a
complete answer.
--Maniac
|
Clarification of Question by
cheekoo1-ga
on
06 Jan 2004 03:49 PST
Well thanks !!!
I think that I will definitely grant that answer to you, if you just
describe the solution in detail.The how and why of the answer ... Also
caveats /Exceptions if any ...
I am not sure if what I am asking now warrants a another question.I
want to know if there is a way to extrapolate
/axn/xyz/*.jsp to let us say 5 lines like
/axn/xyz/1.jsp
/axn/xyz/2.jsp
/axn/xyz/3.jsp
/axn/xyz/4.jsp
/axn/xyz/5.jsp
|