Search Results

Search: Posts Made By: Zooma
1,841
Posted By drysdalk
Hi, In general, if a command works at the...
Hi,

In general, if a command works at the shell prompt, it should work if that same command is put in a script that is run by that same shell. What might be happening here perhaps is that paths...
3,784
Posted By Don Cragun
With any POSIX conforming shell, you could also...
With any POSIX conforming shell, you could also do this entirely in the shell:
#!/bin/ksh
while IFS= read -r line
do printf 'Processing %s\n' "$line"
set -- $line
ip=$1
tm=$2
shift 2...
3,784
Posted By RavinderSingh13
Hello Zooma, Could you please try following...
Hello Zooma,

Could you please try following too and let us know if this helps.
Let's say following is Input_file.

18:70:9f:e3:80:aa 10:11:15 My Wi-Fi Network 2437
18:70:9f:e3:80:aa 10:11:15...
3,784
Posted By Corona688
If it's not comma-separated, it's not CSV. ...
If it's not comma-separated, it's not CSV. You've got a flatfile.

awk '{ S=""; for(N=3; N<NF; N++) S=S "_" $N ; print $1, $2, substr(S,2), $NF }' inputfile
3,134
Posted By Don Cragun
I'm glad that you got it to work. With your...
I'm glad that you got it to work. With your updated scripts, what happens if you just use:
0-59/5 * * * * /usr/myFolder/start.sh
(leaving off the &)? If you're trying to avoid having cron send...
3,134
Posted By RudiC
That's what cron is made for, given its...
That's what cron is made for, given its "features" are dealt with, e.g. sourcing various .profile scripts in the beginning of your scripts, as proposed above.
How exact does the start of the various...
3,134
Posted By Don Cragun
Just using /etc/profile to set the environment...
Just using /etc/profile to set the environment for a user's cron job probably isn't going to help much. There is a good chance you'll also need the user $HOME/.profile, $HOME/.bashrc, or some other...
3,134
Posted By Corona688
cron uses a very minimal path. I suggest setting...
cron uses a very minimal path. I suggest setting your own PATH, or sourcing /etc/profile, in your scripts or it may not find all the commands they need.

0-59/5 * * * * . /etc/profile ;...
3,134
Posted By RavinderSingh13
Hello Zooma, If you want your script to run...
Hello Zooma,

If you want your script to run each 5th minute then could you please try following into your crontab by doing crontab -eand let us know if this helps you.
...
3,134
Posted By RudiC
Any error messages? I guess it starts but doesn't...
Any error messages? I guess it starts but doesn't find the two scripts called. cron only provides a minimalistic environment, so you need to either define your own or use absolute pathnames for...
3,134
Posted By Corona688
That's pretty much what cron already does for you...
That's pretty much what cron already does for you -- sleeps an exact interval, corrects, and runs your program.
3,134
Posted By wbport
Can you insert a sleep command into the loop? If...
Can you insert a sleep command into the loop? If it kicked off a background job every five minutes, sleep 300 would do the job. If every five minutes was a definite goal, code to create a time five...
3,134
Posted By Corona688
Use cron to run things you're scheduling...
Use cron to run things you're scheduling regularly, put it in your crontab(crontab -e) like this:

0-59/5 * * * * /path/to/script.sh

Edit your cron table with cron -e. If you get errors, try...
1,458
Posted By Don Cragun
Note that your script: #!/bin/bash awk ' { ...
Note that your script:
#!/bin/bash
awk '
{
if(!($1 in c))
{
colors[$1] = $1
}
TotalValue[$1] += $2
occurrences[$1]++
}

END { ...
1,458
Posted By RavinderSingh13
Hello Zooma, You could try following too and...
Hello Zooma,

You could try following too and let us know how it goes for you.

awk 'BEGIN{print "Color Occurrence Mean Value" ORS "===== ============ =========="}...
1,458
Posted By RudiC
- the array c is not populated; I guess you...
- the array c is not populated; I guess you want to use colors
- occurrences is misspelled/inconsistently spelled in different places
- the %12d format can't print decimals for mean values

Try...
1,458
Posted By bakunin
Actually one: put "\n" at the end of your...
Actually one: put "\n" at the end of your printf()s, because linefeeds do not come automatically. ;-))

I hope this helps.

bakunin
1,829
Posted By frank_rizzo
Yes. Use something like the curl(1)...
Yes. Use something like the curl(1) (https://www.unix.com/man-page/all/1/curl) command.
3,045
Posted By RudiC
Dynamic case:awk ' FNR==NR {a[$1]=$2 ...
Dynamic case:awk '
FNR==NR {a[$1]=$2
d="-"
for (i=3; i<=NF; i++) {a[$1]=a[$1] FS $i; d=d FS "-"}
next
}
...
3,045
Posted By Chubler_XL
If you sort your files you can then use join: ...
If you sort your files you can then use join:

$ join -j 1 -e "-" -a 1 -a 2 -o 0,1.2,1.3,2.2,2.3,2.4 file1.sor file2.sor
Blackberry dark 4 sour 4 3
Blueberry blue 14 tasty 12 78
Raspberry red 12...
3,045
Posted By RudiC
You're not too far off:awk 'FNR==NR{a[$1]=$2 FS...
You're not too far off:awk 'FNR==NR{a[$1]=$2 FS $3 FS $4;next}{ print $0, a[$1]?a[$1]:"- -"; delete a[$1]} END {for (i in a) print i, "- -", a[i]}' file2 file1
Blueberry blue 14 tasty 12 78...
1,894
Posted By Don Cragun
Hopefully, you'll see how easy all of these...
Hopefully, you'll see how easy all of these pieces fit together soon...
awk -v A="$(date "+%y%m%d %T")" '{print A,$0}' file.txt
1,894
Posted By Don Cragun
And, if someone is using a shell that doesn't...
And, if someone is using a shell that doesn't accept $(<file), and file1.txt just contains one line, you could use:
IFS= read -r A < file1.txt; awk -v A="$A" '{print A,$0}' file.txtor, entirely in...
1,894
Posted By MadeInGermany
If you get an error message, prevent word...
If you get an error message, prevent word splitting with quotes: ... A="$(<file1.txt)" ...
1,894
Posted By MadeInGermany
If post #3 did not produce an error then this...
If post #3 did not produce an error then this should work, too.
awk -v A=$(<file1.txt) '{print A,$0}' file.txt
Showing results 1 to 25 of 41

 
All times are GMT -4. The time now is 04:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy