Im learning bash scrpting language and im making a script that read a file line by line and it does a comparison if in a line start with a letter or number and it will delete every ones that start with a letter. But im getting some errors
First of all, this is the script's code
Quote:
#VARIABLES GLOBALES DEL SCRIPT
IP=$1
ARCHIVO=arch.txt
#VARIABLE PARA COMPARAR POR NUMERO AL INICIAR UNA LINEA
NUM0=(0 1 2 3 4 5 6 7 8 9)
while read line;
do
$line
if [ $line -ne $NUM0 ]; then
sed '/${line}/d' $ARCHIVO
fi
done < $ARCHIVO
echo "PROCESO TERMINADO."
The error that im getting is when the process arrive to while. It starts the conditional and never end. It always is running and showing numbers in the command line. I'd like to know how to solve this problem.
PD When i check out the arch.txt i see that the IF works fine, it delete every line that start with a letter. As i explained above, the problem is with while...
Thanks in advantage for any help that you could give me.
@alienrunes: first you are saving some column from each line in "myarchive.log" into $ARCHIVO (arch.txt), then in the while loop you are doing "sed" for the whole $ARCHIVO for each line in $ARCHIVO...
I could solve the problem from a different way. I've changed the "while" sentence for the "tr" and "grep" commands.
Quote:
Corona688 Please post the input you have and the output you want. Without that, we can't even see how it's going wrong, let alone what or why.
I'm pretty sure you can do what you want with an awk one-liner instead of running sed 9,000 times to process 9,000 lines.
Well the main idea is to get the TIME spent by an user on internet. So, i pass as parameter the IP address and i get time expressed in seconds, but i need to clean that file from non-numerical character, so i delete any special or alphabetic character from that file. After, i delete the empty lines and add (+) the time 'till to get all seconds. After i convert it in hours:minutes:second. All expressed is the goal of this script. I leave below something i've done.
in addition with AWK (Commented in the script)
It works well, but when start to convert from seconds to hh:mm:ss , it shows me the following error.
I've run the command in the console and it works very good. It gives me the time as i want, for instance
Now, in addition with DATE Command
It show me weird values, if i run it with 3600 seconds, it convert in 01:00:00 as expected. But when it has big values, then show wrong value in the converter, for instance:
Quote:
user@myserver:/home/fortinet_syslog# date -d '1970-01-01 3600 sec' +"%H:%M:%S"
01:00:00
user@myserver:/home/fortinet_syslog# date -d '1970-01-01 15000 sec' +"%H:%M:%S"
04:10:00
user@myserver:/home/fortinet_syslog# date -d '1970-01-01 2356174 sec' +"%H:%M:%S" 06:29:34
user@myserver:/home/fortinet_syslog# date -d '1970-01-01 235617 sec' +"%H:%M:%S" 17:26:57
What can i do in these cases? Because i need to get real values from the converter between seconds to hours:minutes:seconds . If there is a way more easy to do it, just let me know how make it.
Hello all,
I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly.
My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Hello,
i have below shell script to process ftp get from server and create file list afte finish.
this shell scipt has 6 parameter input.
unfortunately, it is only working to get the file and terminated before creating file list.
please help.
thanks,
#!/bin/ksh
## example usage :... (3 Replies)
Hi ,
I am using the below command in script. $_IDLETIME is returning value if i execute the script manually.
sar > $_LOCATION/sar.txt
_IDLETIME=`tail -2 $_LOCATION/sar.txt | head -1 | tr -s ' ' ' ' | cut -d ' ' -f8 | cut -d '.' -f1`;
if
But it s not returning any value if it put the... (3 Replies)
Hi GURU's,
I'm using a Shell Script to send email's as an attachment.
I'm Storing the email address in a table and catching in a variable.
MAILLIST=`noarg sqlplus -s $OraUsr << EOF
set heading off
set feedback off
set echo off
SELECT email_ids
FROM tpemail_table
WHERE... (9 Replies)
I am trying to create a Unix script that when ran will provide a veiw of the files of the week that the user inputs, I have this one down. Then I would like them to be able to type in one of the files that is in that week and it displays that file. The script that I have keeps looping the week... (4 Replies)
Hi
I am a novice Linux/Perl user and am struggling to overcome what I am sure is a simple problem.
I am using a perl program to create a shell script daily containing between 10 and 30 "at -f" commands for the same day. Then I change the file attributes to allow the file to be executed. When... (2 Replies)
I have a simple script that checks for certain printers and records them to a file.
When I run the script manually at the command prompt, it works perfect, but when I run the script via cron, nothing happens. No errors reported, and no records are written out. I'm using Solaris 10. Below is the... (4 Replies)
I created a script before which was this :-
cd /mike/dataxfer
for dir in *; do
if ; then
ssh -l abc nissan "mkdir -p /mike/web/$dir"
scp -r ${dir}/priceops nissan:mike/web/${dir}/
fi
done
exit 0
This script worked fine for me with no problem. It will... (5 Replies)
I am new to unix, and this is my 1st post on this board. Looking for some advice about a cron job in my server.
I am running a cron task that references a script which runs several other scripts and compiles them into a report and emails it to me. If I run the script manually, I will... (2 Replies)