Last occurrence of code between two tags


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Last occurrence of code between two tags
# 22  
Old 01-25-2012
I tried to execute ./configure, make and make install separately. First two commands executed well, but make install has given me some error given below
Code:
Making install in .
test -z "/usr/local/bin" || ./install-sh -c -d "/usr/local/bin"
  ./install-sh -c gawk pgawk '/usr/local/bin'
cp: cannot create /usr/local/bin/_inst.29664_: Permission denied
*** Error code 2
The following command caused the error:
list='gawk pgawk'; test -n "/usr/local/bin" || list=; \
for p in $list; do echo "$p $p"; done | \
sed 's/$//' | \
while read p p1; do if test -f $p; \
  then echo "$p"; echo "$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
    -e 'p;x;s,.*/,,;s/$//;s,x,x,;s/$//' | \
sed 'N;N;N;s,\n, ,g' | \
nawk 'BEGIN { files["."] = ""; dirs["."] = 1 } \
  { d=$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
    if ($2 == $4) files[d] = files[d] " " $1; \
    else { print "f", $3 "/" $4, $1; } } \
  END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
    if test "$dir" = .; then dir=; else dir=/$dir; fi; \
    test -z "$files" || { \
      echo "  ./install-sh -c $files '/usr/local/bin$dir'"; \
       ./install-sh -c $files "/usr/local/bin$dir" || exit $?; \
    } \
; done
make: Fatal error: Command failed for target `install-binPROGRAMS'
Current working directory /admin/home/v119312/gawk-3.1.8
*** Error code 1
The following command caused the error:
make 'CFLAGS=-g -O2' 'LDFLAGS=' install-exec-am install-data-am
make: Fatal error: Command failed for target `install-am'
Current working directory /admin/home/v119312/gawk-3.1.8
*** Error code 1
The following command caused the error:
fail= failcom='exit 1'; \
for f in x $MAKEFLAGS; do \
  case $f in \
    *=* | --[!k]*);; \
    *k*) failcom='fail=yes';; \
  esac; \
done; \
dot_seen=no; \
target=`echo install-recursive | sed s/-recursive//`; \
list='.  awklib  doc  po  test'; for subdir in $list; do \
  echo "Making $target in $subdir"; \
  if test "$subdir" = "."; then \
    dot_seen=yes; \
    local_target="$target-am"; \
  else \
    local_target="$target"; \
  fi; \
  (CDPATH="${ZSH_VERSION+.}:" && cd $subdir && make 'CFLAGS=-g -O2' 'LDFLAGS=' $local_target) \
  || eval $failcom; \
done; \
if test "$dot_seen" = "no"; then \
  make 'CFLAGS=-g -O2' 'LDFLAGS=' "$target-am" || exit 1; \
fi; test -z "$fail"
make: Fatal error: Command failed for target `install-recursive'

Also, I tried to execute the following code to get the version

Quote:
Code:
sed --version | head -n 1
error is given below

Code:
cig4s323z1$ sed --version | head -n 1
sed: illegal option -- version

Quote:
sed -e '/.*<'$r'>.*/{x;p;x}' -e '/<\/'$r'>/G'
It is still giving me garbled error.

Quote:
sed -e '/.*<'$r'>.*/{x p x }' -e '/<\/'$r'>/G' file
It is giving some incorrect lines from log file.


I put the perl script in some file called lastResponse.pl and executed like
perl lastResponse.pl inputfile

It worked great and got my last occurred response for my user in two minutes. Thank You Mirni for your continuous support.
# 23  
Old 01-25-2012
Well I am also very happy you got what you wanted. Ufff....
Just for the record, the error you were getting with 'make install' was
Code:
 Permission denied

You need to elevate to root's privileges to install system wide. If you used --prefix=/mydir with ./configure, you could install it into your directory. But 'make' has finished building so should have gawk binary present in the gawk-3.1.8 directory. Instead of the clumsy perl script, you can use gawk oneliner posted earlier in this thread. Something like this:
Code:
/path/to/gawk '/<user>user1/&&/<response1>/{a=$0 RT}END{print a}' RS="</response[0-9]*>" xmlFile

# 24  
Old 01-27-2012
Hi Mirni,

Your perl script was working so I thought I should finish my pending work with that only. Today I got some time to see how gawk command is working.

You are awesome. It worked well.

Thank You So much.

My best wishes to you.

unix.com should give us an option to post questions directly to someone they are confident on.... If so, I would shoot all my questions on unix to you ..Smilie Smilie Smilie Smilie

Narayana.V
# 25  
Old 01-27-2012
Glad I could be of help.
Quote:
unix.com should give us an option to post questions directly to someone they are confident on.... If so, I would shoot all my questions on unix to you ..Smilie Smilie Smilie Smilie
This is a public forum, which has a good reason -- it helps people find their solution, when they google it up, and the more people have access to it, the better chances for fast and accurate response. Asking questions directly through private messages is against the rules of the forum, and for a good reason.
I am no guru; there are much more competent people here, which gives me and others an opportunity to improve our skills. The power is in the community, community is the keyword when dealing with open-source software.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed print from last occurrence match until the end of last occurrence match

Hi, i have file file.txt with data like: START 03:11:30 a 03:11:40 b END START 03:13:30 eee 03:13:35 fff END jjjjjjjjjjjjjjjjjjjjj START 03:14:30 eee 03:15:30 fff END ggggggggggg iiiiiiiiiiiiiiiiiiiiiiiii I want the below output START (13 Replies)
Discussion started by: Jyotshna
13 Replies

2. UNIX for Dummies Questions & Answers

Code for exact match to count occurrence

Hi all, I have an input file as below. I would like to count the occurrence of pattern matching 8th field for each line. Input: field_01 field_02 field_03 field_04 field_05 field_06 field_07 field_08 TA T TA T TA TA TA... (3 Replies)
Discussion started by: huiyee1
3 Replies

3. Shell Programming and Scripting

Substitute first occurrence of keyword if occurrence between two other keywords

Assume a string that contains one or multiple occurrences of three different keywords (abbreviated as "kw"). I would like to replace kw2 with some other string, say "qux". Specifically, I would like to replace that occurrence of kw2 that is the first one that is preceded by kw1 somewhere in the... (4 Replies)
Discussion started by: M Gruenstaeudl
4 Replies

4. Shell Programming and Scripting

number of occurrence

: i need a bash script to convert the displayed output 12 14 15 12 15 13 to 12 * 2 ,13 * 1,14*1,15*1 Thanks, nevil (2 Replies)
Discussion started by: nevil
2 Replies

5. Shell Programming and Scripting

Replace second occurrence only

HPUX /bin/sh (posix) I have a file as such cat dog mouse deer elk rabbit mouse rat pig I would like to replace the second occurrence of mouse in this file with mouse2. The rest of the file has to stay exactly as is. I'm not sure exactly where mouse might be (could be first,second,third... (5 Replies)
Discussion started by: lyoncc
5 Replies
Login or Register to Ask a Question