05-15-2013
For anyone reading this, the moral of this thread is ... if you don't spoonfeed the hungry, they won't thank you.
You're welcome,
Alister
This User Gave Thanks to alister For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I seem to have gotten myself in over my head on this one. I need help combining lines together.
I have a text file containing 24,000 lines (exactly why I need awk) due to bad formatting it has separated the lines (ideally it should be 12,000 lines total).
Example of file:
... (2 Replies)
Discussion started by: blueheed
2 Replies
2. Shell Programming and Scripting
I am using:
ps -A -o command,%cpu
to get process and cpu usage figures. I want to use awk to split up the columns it returns. If I use:
awk '{print "Process: "$1"\nCPU Usage: "$NF"\n"}'
the $NF will get me the value in the last column, but if there is more than one word in the... (2 Replies)
Discussion started by: json4639
2 Replies
3. UNIX for Dummies Questions & Answers
It would be convenient to be able to combine awk tests. For example, suppose that I do this query:
awk '$1 != "Bob" || $1 != "Linda" {print $2}' datafileIs there a reasonable way to combine the conditions into a single statement? For example, in egrep, I can do:
egrep -v "Bob|Linda"... (4 Replies)
Discussion started by: treesloth
4 Replies
4. Shell Programming and Scripting
I have a file like this consisting of blocks separated by > of two number X and T
>
10 0
13 5.92346
16 10.3106
19 13.9672
22 16.9838
25 19.4407
28 21.4705
31 23.1547
34 24.6813
37 26.0695
40 27.3611
43 28.631
46 29.8366
49 30.9858
52 32.0934
55 33.1458 (6 Replies)
Discussion started by: kristinu
6 Replies
5. Shell Programming and Scripting
I have a pretty simple script below:
#!/bin/sh
for i in *.cfg
do
temp=`awk '/^InputDirectory=/' ${i}`
input_dir=`echo ${temp} | awk '{ print substr( $0, 16) }'`
echo ${input_dir}
done
As you can see its opening each cfg file and searching for the line that has "InputDirectory="... (3 Replies)
Discussion started by: ssbsts
3 Replies
6. Shell Programming and Scripting
Hi experts,
I have a requirement, In which I need to display the first and last line of a zip file where the line starts with "L". I've writen the code like below using sed and awk.
gunzip -c 20110203.1104.gz | awk '$1 ~ "^L" {print substr($0,178,15)}' | sed -n '1p;$p'
Is it possible to do it... (8 Replies)
Discussion started by: senthil.ak
8 Replies
7. Shell Programming and Scripting
Hello UNIX Community,
I have file that contains the following data:
testAwk2.csv
rabbit penguin goat
giraffe emu ostrich
hyena elephant panda
dog cat pig
lizard snake antelope
platypus tiger cheetah
lion rhino spider
I then find the character length of the... (1 Reply)
Discussion started by: vnayak
1 Replies
8. Shell Programming and Scripting
I can achieve two tasks with 2 different awk commands:
1) awk -F";;WORD" '{print $2}' file | sed '/^$/d' #to find surface_word
2) awk -F"bw:|gloss:" '// {print $2}' file | sed '/\//!d; s:/*+*: + :g; s:^+::; s: *+ *$::;' #to find segmentation of surface_word
Number 1) finds surface_word... (7 Replies)
Discussion started by: Viernes
7 Replies
9. Shell Programming and Scripting
i have a datafile that has several lines that look like this:
2,dataflow,Sun Mar 17 16:50:01 2013,1363539001,2990,excelsheet,660,mortar,660,4
using the following command:
awk -F, '{$3=strftime("%a %b %d %T %Y,%s",$3)}1' OFS=, $DATAFILE | egrep -v "\-OLDISSUES," | ${AWK} "/${MONTH} ${DAY}... (7 Replies)
Discussion started by: SkySmart
7 Replies
10. Shell Programming and Scripting
the following code works perfectly for me:
# AWK 1
gawk -F, '/,'${ThisMonthDOW}' '${ThisMonthMON}' :: '${ThisMonthYEA}',/ {
if (NF == 10)
... (6 Replies)
Discussion started by: SkySmart
6 Replies
LEARN ABOUT HPUX
pthread_rwlock_rdlock
pthread_rwlock_rdlock(3T) pthread_rwlock_rdlock(3T)
NAME
pthread_rwlock_rdlock(), pthread_rwlock_tryrdlock() - lock or attempt to lock a read-write lock for reading
SYNOPSIS
PARAMETERS
rwlock Pointer to the read-write lock to be locked for reading.
DESCRIPTION
The function applies a read lock to the read-write lock object referenced by rwlock. The calling thread shall acquire a read lock if a
writer does not hold the lock and there are no writers blocked on the lock. It is unspecified whether the calling thread acquires the lock
when a writer does not hold the lock and there are writers waiting for the lock. If a writer holds the lock, the calling thread shall not
acquire the read lock. If the read lock is not acquired, the calling thread blocks (that is, it does not return from the call) until it
can acquire the lock. Results are undefined if the calling thread currently owns a write lock on rwlock.
Implementations shall be allowed to favor writers over readers to avoid writer starvation.
A thread may hold multiple concurrent locks on rwlock (that is, successfully call the function n times). If so, the thread must perform the
matching unlocks (that is, it must call the function n times).
The function applies a read lock as in the function with the exception that the function fails if any thread holds a write lock on rwlock
or there are writers blocked on rwlock.
Results are undefined if any of these functions are called with an uninitialized read-write lock.
If a signal is delivered to a thread waiting for a read-write lock, upon return from the signal handler, the thread shall resume waiting
for the read-write lock as if it was not interrupted.
RETURN VALUE
Upon successful completion, and return zero. Otherwise, an error number is returned to indicate the error (the variable is not set).
ERRORS
If any of the following occur, the function returns the corresponding error number:
[EBUSY] The read-write lock rwlock could not be acquired for reading because a writer holds the lock or was blocked on it.
For each of the following conditions, if the condition is detected, the and functions return the corresponding error number:
[EINVAL] The value specified by rwlock does not refer to an initialized read-write lock.
[EDEADLK] The current thread already owns the read-write lock for writing.
[EAGAIN] The read lock could not be acquired because the maximum number of read locks for rwlock has been exceeded. This error
is not detected on HP-UX.
AUTHOR
and were developed by X/Open.
SEE ALSO
pthread_rwlock_init(3T), pthread_rwlock_destroy(3T), pthread_rwlock_trywrlock(3T), pthread_rwlock_wrlock(3T), pthread_rwlock_unlock(3T).
STANDARDS CONFORMANCE
Pthread Library pthread_rwlock_rdlock(3T)