In article <1931f5f1-efe3-44b2-a764-272fe0543...@thehobsons.co.uk>, Simon Hobson <li...@thehobsons.co.uk> wrote: > maxmax20 <mak.ad...@zoho.com> wrote: > > > rrdtool update /home/pi/net/net.rrd N:'cut -d, /home/pi/net/devices.csv -f13 > > | cut -d: -f2'::::: to get the first value out of the csv file, but it seems > > that it won't work. > > As suggested, put echo in front of it - and possibly pipe the output through > hexdump. > > One thought, does the SCV file contain exactly one line - not zero lines, not > 2 lines (having one line and a newline counts as 2 lines). You may want to > add "head -1" > > If working in bash, you can cut things down somewhat by using Bash builtin > string functions - one some of my data collection scripts, it's made a huge > difference. When you use cut you are spawning two new processes (three is you > add head as well). > > Check the man page for parameter expansion, specifically the > ${parameter#word}, ${parameter##word}, ${parameter%word}, and > ${parameter%%word} forms. I think this will get you your value : > > # Get the file > Utmp=$( < /home/pi/net/devices.csv ) > > # Get everything after the 12th ',' > Utmp=$(Utmp#*,*,*,*,*,*,*,*,*,*,*,*,)
Always dangerous to type suggestions on the fly without testing! (been there, done that) I think you mean ${ ... } not $( ... ), and similarly on the next two. > # Get everything after the first ':' > Utmp=$(Utmp#*:) > > # Optional - depends on your file, delete everything after the next , or : > Utmp=$(Utmp%%,*) or Utmp=$(Utmp%%:*) > > > Don't think it applies here (though I don't know if fiddling with IFS might > help), but another trick you could try is using arrays. My specific action > was getting traffic counts from an interface, so I have a script with : > Utmp=$(< /proc/net/dev) > Utmp=(${Utmp#*ethext:}) > UpdateVal=${Utmp[0]}:${Utmp[8]} > I'll leave you to figure it out. > > > PS - no I didn't come up with this myself, someone else pointed me in that > direction. > > _______________________________________________ > rrd-users mailing list > rrd-users@lists.oetiker.ch > https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users > -- Tony Mountifield Work: t...@softins.co.uk - http://www.softins.co.uk Play: t...@mountifield.org - http://tony.mountifield.org _______________________________________________ rrd-users mailing list rrd-users@lists.oetiker.ch https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users