Hello, i have a problem with the output from my bash program.
I made this program
Code:
#!/bin/bash
BESTANDEN=$* # Plaatst bestanden in de variabele BESTANDEN
TMPFILE=xmlprog.sh.$$.$RANDOM # basisnaam voor tijdelijke bestanden
# controller of het programma correct is aangeroepen
if [ -z "$BESTANDEN" ]
then
echo "FOUT: Er zijn geen bestanden opgegeven!" >&2
exit
fi
for i in "$BESTANDEN"
do
# Delete XML TAGS
sed -e 's/></>\n</g' $i | sed 's/<\/.*>//g' | sed 's/.*\(<.*>\).*/\1/' | sed '/^$/d' | wc -l
echo "${i}"
done
#!/bin/bash
BESTANDEN=( "$@" ) ## Put arguments in array
TMPFILE=xmlprog.sh.$$.$RANDOM
if [ $# -eq 0 ] ## If no arguments...
then
echo "FOUT: Er zijn geen bestanden opgegeven!" >&2
exit 1
fi
for i in "${BESTANDEN[@]}"
do
# Delete XML TAGS
sed -e 's/></>\n</g' $i | sed 's|</.*>||g' | sed -e 's/.*\(<.*>\).*/\1/' -e '/^$/d' | wc -l
printf "%s\n" "$i"
done
#!/bin/bash
BESTANDEN=$* # Plaatst bestanden in de variabele BESTANDEN
TMPFILE=xmlprog.sh.$$.$RANDOM # basisnaam voor tijdelijke bestanden
# controller of het programma correct is aangeroepen
if [ -z "$BESTANDEN" ]
then
echo "FOUT: Er zijn geen bestanden opgegeven!" >&2
exit
fi
for i in $BESTANDEN
do
# Delete XML TAGS
echo $(sed -e 's/></>\n</g' $i | sed 's/<\/.*>//g' | sed 's/.*\(<.*>\).*/\1/' | sed '/^$/d' | wc -l) " opening tags in file " $i
done
#!/bin/bash
BESTANDEN=$* # Plaatst bestanden in de variabele BESTANDEN
TMPFILE=xmlprog.sh.$$.$RANDOM # basisnaam voor tijdelijke bestanden
# controller of het programma correct is aangeroepen
if [ -z "$BESTANDEN" ]
then
echo "FOUT: Er zijn geen bestanden opgegeven!" >&2
exit
fi
for i in $BESTANDEN
do
# Verwijderen XML TAGS
sed -e 's/></>\n</g' $i | sed 's/<\/.*>//g' | sed 's/.*\(<.*>\).*/\1/' | sed '/^$/d' | wc -l > $TMPFILE-1
echo " XML opening tags in bestand: ${i}" > $TMPFILE-2
paste -d '' $TMPFILE-1 $TMPFILE-2
done
rm -f $TMPFILE-1 $TMPFILE-2
But is have a collection of 500+ xml files. So i like to have 10 xml files with the most xml tags.
---------- Post updated at 11:01 AM ---------- Previous update was at 07:47 AM ----------
Hello, i have this solution
Code:
#!/bin/bash
#countxmlprog.sh : telt het aantal xml open tags uit bestanden
# aanroepen als: countxmlprog.sh bestanden
# Auteur: s2065460, frank.spin89@gmail.com
BESTANDEN=$* # Plaatst bestanden in de variabele BESTANDEN
TMPFILE=xmlprog.sh.$$.$RANDOM # basisnaam voor tijdelijke bestanden
# controller of het programma correct is aangeroepen
if [ -z "$BESTANDEN" ]
then
echo "FOUT: Er zijn geen bestanden opgegeven!" >&2
exit
fi
for i in $BESTANDEN
do
# Verwijderen XML TAGS
sed -e 's/></>\n</g' $i | sed 's/<\/.*>//g' | sed 's/.*\(<.*>\).*/\1/' | sed '/^$/d' | wc -l > $TMPFILE-1
echo " XML opening tags in bestand: ${i}" > $TMPFILE-2
paste -d ' ' $TMPFILE-1 $TMPFILE-2 >> $TMPFILE-3
done
cat $TMPFILE-3 | sort -nr | head
rm -f $TMPFILE-1 $TMPFILE-2
This is my right solution.
Can i made a kind of fallback behavior when the user is not entering a file name? Now he gets a error like: "ERROR: NO File"
Some of my admin made some changes on my Solaris-10 box and after that I started getting this wiered issue. I checked path, but not able to figure it out. This is for a non-root user
gcadmin@brbpod06: $ echo $SHELL
/usr/bin/bash
gcadmin@brbpod06: $ bash
bash: brbpod06:: command not found... (2 Replies)
I have written the following bash function prArgv
Suppose the calling sequence is as follows
prArgv VAL1 VAL2 DESC VAL3 VAL4 v2d1 s4 p15
The call will look at the tag k1v2, add the numbers together, in this case 2+1=3
This means that the function will look at the first 3 user arguments... (1 Reply)
I have a ksh script (script1) that calls another ksh script (script2). If script2.ksh hangs or takes too long to execute I want script1.ksh to kill the call to script2.ksh and instead just display "Script2 can't run right now". Could someone help me with coding this? (1 Reply)
Hi
I was wondering how can a c program will be implemented which will display a symbol while calculating something.
for example : program should display some charters like /\/\ while calculating.
At least provide some pointers
thanks (4 Replies)
Hi All,
I have created a sample perl program in one of the unix environment as below
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<H1>Hello World</H1>";
When I execute it in unix, I get the below
Content-type: text/html
<H1>Hello World</H1>
However, when I... (1 Reply)
I am new to C programming. I have been trying to display unique lines in a file from past two days. The problem is here,
I have a file whose contents are,
ras.beamtele.net
ras.beamtele.net
ras.beamtele.net
ras.beamtele.net
ras.beamtele.net
ras.beamtele.net
ras.beamtele.net... (1 Reply)
Hi folks,
Please advise which command/command line shall I run;
1) to display the command and its output on console
2) simultaneous to save the command and its output on a file
I tried tee command as follows;
$ ps aux | grep mysql | tee /path/to/output.txt
It displayed the... (7 Replies)
I'm on a Linux machine and need a program that will display user information as follows: user name, user directory and current date & time.
I think we can compile C, C++ and Perl.
All help is appreciated. (4 Replies)
An interesting puzzle. I run character based compiled C-Programs in a Unix environment on PCs in a Window. I want to be able to call up and display in a separate window a picture of a product called by a Unix shell script from within my Unix program.
Ideally I would like to have a script that... (4 Replies)
Hi All,
I have one AIX box (5.1 with CDE running) and one Linux box ( FC3 with GNOME on it). What I want to be able to do is : SSH from the Linux box into the AIX box and then open an X term to launch a X window application. I am not able to do that. My guess is that the window mangers and... (4 Replies)