11-03-2010
thx Scrutinizer. you have again a perfect solution
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello Experts,
I am back, with another doubt. I am not sure what it relates to this time - awk or the print command actually. I'll explain the scenario:
I have a huge file, and it has some traces(logs). In between those logs, there are statements with some SQL queries. All I want to do is... (4 Replies)
Discussion started by: hkansal
4 Replies
2. UNIX for Dummies Questions & Answers
Hi Friends,
Scripting newb here. So I'm trying to create a geektool script that uses awk and printf to output certain fields from top (namely command, cpu%, rsize, pid and time, in that order).
Here's the input from the top process that I'm putting into awk:
PID COMMAND %CPU ... (3 Replies)
Discussion started by: thom.mattson
3 Replies
3. Shell Programming and Scripting
Hi
I need to check if field separator I am using in awk statement is " : ", for example:
TIME=12:59
HOUR=`echo "$TIME" | awk '{FS=":"; print $1}'`
MINUTES=`echo "$TIME" | awk '{FS=":"; print $2}'`
Is there a way to check within the above awk statement ?
Thanks for help -A (2 Replies)
Discussion started by: aoussenko
2 Replies
4. Shell Programming and Scripting
Hi, all
I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes.
sample input:
for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies
5. Shell Programming and Scripting
I am using this code to insert something into a csv file:
awk -F";" -v url=$url -v nr=$nr 'NR==nr{$2=url$2}1' file
Why do I get the output
field1 field2
instead of
field1;field2
I have given -F";", so the field separator should surely be ";". (1 Reply)
Discussion started by: locoroco
1 Replies
6. UNIX for Dummies Questions & Answers
In awk, how do I print all fields with a specified output field separator?
I have tried the following, which does not print the output FS:
echo a b c d | awk 'BEGIN{OFS = ";"}{print $0}' (3 Replies)
Discussion started by: locoroco
3 Replies
7. Shell Programming and Scripting
I need to set awk field separator to ";", but I need to avoid ";EXT".
so that
echo a;b;c;EXTd;e;f | awk -F";" '{print $3}'
would give "c;EXTd" (2 Replies)
Discussion started by: locoroco
2 Replies
8. Shell Programming and Scripting
Hi Experts ,
file :
- How to construct the awk filed separator so that $1, $2 $3 , can be assigned to the each "" range.
I am trying : awk -F"]" '{print $1}'
but it is printing the entire file. Not first field.
The desired output needed for first field... (9 Replies)
Discussion started by: rveri
9 Replies
9. Shell Programming and Scripting
I can not figure out how to set the Output filed separator in awk when using printf.
Example:
cat file
some data
here_is_more information
Requested output
some------------data
her_is_more-----information
Here are some that does not work:
awk '{printf "%-15s %s\n",$1,$2}' OFS="-" file... (9 Replies)
Discussion started by: Jotne
9 Replies
10. UNIX for Beginners Questions & Answers
Hi, can some some help to get me the right results,
I have few text files, need to grep few columns from each file and get the results in one row with comma separated.
my code is
#folder=/nz/kit/log/backupsvr
folder=/export/home/nz/valai/tmpfiles/
echo $folder
for entry in `ls... (4 Replies)
Discussion started by: ValaiG
4 Replies
LEARN ABOUT NETBSD
nbperf
NBPERF(1) BSD General Commands Manual NBPERF(1)
NAME
nbperf -- compute a perfect hash function
SYNOPSIS
nbperf [-ps] [-a algorithm] [-c utilisation] [-h hash] [-i iterations] [-m map-file] [-n name] [-o output] [input]
DESCRIPTION
nbperf reads a number of keys one per line from standard input or input. It computes a minimal perfect hash function and writes it to stdout
or output. The default algorithm is "chm".
The -m argument instructs nbperf to write the resulting key mapping to map-file. Each line gives the result of the hash function for the
corresponding input key.
The parameter utilisation determines the space efficiency.
Supported arguments for -a:
chm This results in an order preserving minimal perfect hash function. The utilisation must be at least 2, the default. The number of
iterations needed grows if the utilisation is very near to 2.
chm3
Similar to chm. The resulting hash function needs three instead of two table lookups when compared to chm. The utilisation must be at
least 1.24, the default. This makes the output for chm3 noticable smaller than the output for chm.
bpz This results in a non-order preserving minimal perfect hash function. Output size is approximately 2.79 bit per key for the default
value of utilisation, 1.24. This is also the smallest supported value.
Supported arguments for -h:
mi_vector_hash Platform-independent version of Jenkins parallel hash. See mi_vector_hash(3).
The number of iterations can be limited with -i. nbperf outputs a function matching uint32_t hash(const void * restrict, size_t) to stdout.
The function expects the key length as second argument, for strings not including the terminating NUL. It is the responsibility of the call-
er to pass in only valid keys or compare the resulting index to the key. The function name can be changed using -n name. If the -s flag is
specified, it will be static.
After each failing iteration, a dot is written to stderr.
nbperf checks for duplicate keys on the first iteration that passed basic hash distribution tests. In that case, an error message is printed
and the program terminates.
If the -p flag is specified, the hash function is seeded in a stable way. This may take longer than the normal random seed, but ensures that
the output is the same for repeated invocations as long as the input is constant.
EXIT STATUS
The nbperf utility exits 0 on success, and >0 if an error occurs.
SEE ALSO
mi_vector_hash(3)
AUTHORS
Jorg Sonnenberger
BSD
September 25, 2012 BSD