hi all i am trying to save an awk value into an array in bash:
total=`awk '{sum+=$3} END {print sum}' "$count".txt"`
((count++))
the above statement is in a while loop..
$count is to keep track of file numbers (1.txt,2.txt,3.txt,etc.)
i get the following error:
./lines1:... (1 Reply)
greetings all,
I am have a heck of a time trying to accomplish a very simple thing. I have an array of "shortname<spaces>id" created from a dscl output. I want to assign shortname=word1 and id=word2. I have tried
shortname=$(${textArray} | awk '{print $1}') - and get 'awk : cannot open... (3 Replies)
I would like to create a variable within my bash script using awk. I'm reading in a line from an external file, then outputting to a new file in a specific format. But, it doesnt quite work as I have expected and could use some help.
(A pertinent excerpt of ) the bash code is:
count=1
... (4 Replies)
I'm running a curl command in bash, but the & in the middle causes the second half of the line to run in the background, here's what I'm trying to do:
lat="37.451"
lon="-122.18"
url="http://ws.geonames.org/findNearestAddress?lat=$lat&lng=$lon"
curl -s "$url"
I tried escaping the & with \&,... (4 Replies)
Hi,
I'm trying to populate bash script variable, data_size with the
size of the largest file in my current directory
data_size=$(ls -lS | grep -v "total" | head -1) | awk '{ print $5 }'
I've tried adding an echo before the call to awk
data_size=$(ls -l | grep -v "total" | head -1) |... (2 Replies)
How to store escape character in the variable.
Var=abc,def,ghi,jkl
echo ${Var} | sed -e "s/,/|\\\\./g;s/^/\\\\./g"
\.abc|\.def|\.ghi|\.hjk
Var1=`echo ${Var} | sed -e "s/,/|\\\./g;s/^/\\\./g"`
Actual:
-------
echo $Var1
.abc|.def|.ghi|.jkl
Expected:
---------
echo $Var1... (4 Replies)
Hi everyone,
I'm trying to write a small script to automatize row data treatment. However, I got some trouble with the awk command.
I want to use awk to extract a define paragraph from a text file. The first and final lines are defined externally in two variables called debut and fin.
I... (2 Replies)
Hi,
I am new in bash scripting. In my work, I provide support to several users and when I connect to their computers I use the same admin and password, so I am trying to create a script that will only ask me for the IP address and then connect to the computer without having me to type the user... (5 Replies)
Debian 9 64x - LXDE
How can i disable escape sequences in a variable?
#!/bin/bash
#mainscript
. "./links.bash"
echo "$red_start This text should be red $color_end"#!/bin/bash
#links.bash
#colors
red_start="\eOutput that i get:
\e
Output expected:
This text should be... (5 Replies)
Hello,
I need to split a file into two of different locations by re-direction in awk.
cat infle
aaa 1 3
bbb 2 4
aaa 3 3
bbb 4 4
aaa 5 3
bbb 6 4
cat /storage/tmp/group_a.gtf
aaa 1 3
aaa 3 3
aaa 5 3
cat /storage/tmp/group_b.gtf
bbb 2 4
bbb ... (2 Replies)
Discussion started by: yifangt
2 Replies
LEARN ABOUT MOJAVE
tc-police
Policing action in tc(8) Linux Policing action in tc(8)NAME
police - policing action
SYNOPSIS
tc ... action police rate RATE burst BYTES[/BYTES] [ mtu BYTES[/BYTES] ] [ peakrate RATE ] [ overhead BYTES ] [ linklayer TYPE ] [ CONTROL
]
tc ... filter ... [ estimator SAMPLE AVERAGE ] action police avrate RATE [ CONTROL ]
CONTROL := conform-exceed EXCEEDACT[/NOTEXCEEDACT
EXCEEDACT/NOTEXCEEDACT := { pipe | ok | reclassify | drop | continue | goto chain CHAIN_INDEX }
DESCRIPTION
The police action allows to limit bandwidth of traffic matched by the filter it is attached to. Basically there are two different algo-
rithms available to measure the packet rate: The first one uses an internal dual token bucket and is configured using the rate, burst, mtu,
peakrate, overhead and linklayer parameters. The second one uses an in-kernel sampling mechanism. It can be fine-tuned using the estimator
filter parameter.
OPTIONS
rate RATE
The maximum traffic rate of packets passing this action. Those exceeding it will be treated as defined by the conform-exceed option.
burst BYTES[/BYTES]
Set the maximum allowed burst in bytes, optionally followed by a slash ('/') sign and cell size which must be a power of 2.
mtu BYTES[/BYTES]
This is the maximum packet size handled by the policer (larger ones will be handled like they exceeded the configured rate). Setting
this value correctly will improve the scheduler's precision. Value formatting is identical to burst above. Defaults to unlimited.
peakrate RATE
Set the maximum bucket depletion rate, exceeding rate.
avrate RATE
Make use of an in-kernel bandwidth rate estimator and match the given RATE against it.
overhead BYTES
Account for protocol overhead of encapsulating output devices when computing rate and peakrate.
linklayer TYPE
Specify the link layer type. TYPE may be one of ethernet (the default), atm or adsl (which are synonyms). It is used to align the
precomputed rate tables to ATM cell sizes, for ethernet no action is taken.
estimator SAMPLE AVERAGE
Fine-tune the in-kernel packet rate estimator. SAMPLE and AVERAGE are time values and control the frequency in which samples are
taken and over what timespan an average is built.
conform-exceed EXCEEDACT[/NOTEXCEEDACT]
Define how to handle packets which exceed or conform the configured bandwidth limit. Possible values are:
continue
Don't do anything, just continue with the next action in line.
drop Drop the packet immediately.
shot This is a synonym to drop.
ok Accept the packet. This is the default for conforming packets.
pass This is a synonym to ok.
reclassify
Treat the packet as non-matching to the filter this action is attached to and continue with the next filter in line (if any).
This is the default for exceeding packets.
pipe Pass the packet to the next action in line.
EXAMPLES
A typical application of the police action is to enforce ingress traffic rate by dropping exceeding packets. Although better done on the
sender's side, especially in scenarios with lack of peer control (e.g. with dial-up providers) this is often the best one can do in order
to keep latencies low under high load. The following establishes input bandwidth policing to 1mbit/s using the ingress qdisc and u32 fil-
ter:
# tc qdisc add dev eth0 handle ffff: ingress
# tc filter add dev eth0 parent ffff: u32
match u32 0 0
police rate 1mbit burst 100k
As an action can not live on it's own, there always has to be a filter involved as link between qdisc and action. The example above uses
u32 for that, which is configured to effectively match any packet (passing it to the police action thereby).
SEE ALSO tc(8)iproute2 20 Jan 2015 Policing action in tc(8)