We have a ksh which runs once every 15 minutes. Based on a certain condition (for invalid data) we are spooling a file and if the file is of length greater than 0 bytes, then we are mailing this file to a group of users. Upon receiving the file, users correct the data so that on its next run the... (2 Replies)
I have a command stream that will parse down an ftp DIR listing of a remote directory and return the name of the newest file that I am interested in. The command is
sed -e '/^d/d' sppay.listing |sed -n -e '/SPPAY/p'|sort -r -k 43M,45 -k 47,48 -k 50,54|sed -n -e '1p'|cut -c 56-99
and what it... (2 Replies)
Attached is the exact ouput of a vmware VDR log file I am working with but what I am trying to achieve is as follows:
I need to output sections of the file using the string "Normal backup" as the start and "Duration" as the end to seperate files so I can then manipulate them further to create... (2 Replies)
Hello everybody,
I have a requirement in my script..
When i'am executing a script, it'll ask a passwd of some service account.. I need to pass it to the script through a zipped file when it asks for it.
The script can be executed by more people many number times. So for securty purpose, it... (1 Reply)
hi,
I am copying a file from 1 folder to another in /bin/sh. if the file already exists there, it should get copied as filename1. again if copying next time it shouldget copied as filename2.. , filename3..so on..
The problem is i am able to get uptil filename1.. but how do i know what... (6 Replies)
Hi Team ,
Is there a way I can check to see if the same file say , test.dat exists multiple times in the directory path ?
Please help.
Thanks
Megha (5 Replies)
i have to append a text file
grep for a word, if found, put comment in starting of the line.
here is an example
cat test.sh
bin/ksh
Hello World
Test Message
:wq!
search for "bin" word in test.sh file if found comment it out at starting of the line:
Output as follows:
#bin/ksh... (5 Replies)
Hi folks,
Iam working on a bash script, i need to print how many times column 2 repeated at the end of each line.
Input.txt
COL1 COL2 COL3 COL4
1 XX 45 N
2 YY 34 y
3 ZZ 44 N
4 XX 89 Y
5 XX 45 N
6 YY 84 D
7 ZZ 22 S
Output.txt
COL1 COL2 COL3 COL4 COL5
1 XX 45 N 3
2 YY 34... (6 Replies)
First of all, apologies if this has already been answered elsewhere. I haven't quite been able to find what I'm looking for yet, so hopefully this won't come across as repetition.
I have a file consisting of ~100 nearly identical lines, each of which contains multiple instances of the string I... (11 Replies)
Hi All-I am new to Unix , I need to write a script. Can someone help me with a requirement where I have list of files in a directory, I want to Merge the files if a pattern of string matches in filenames?
AAAL_555A_ORANGE1_F190404.TXT
AAAL_555A_ORANGE2_F190404.TXT
AAAL_555A_ORANGE3_F190404.TXT... (6 Replies)
Discussion started by: Shankar455
6 Replies
LEARN ABOUT FREEBSD
counter_u64_alloc
COUNTER(9) BSD Kernel Developer's Manual COUNTER(9)NAME
counter -- SMP-friendly kernel counter implementation
SYNOPSIS
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/counter.h>
counter_u64_t
counter_u64_alloc(int wait);
void
counter_u64_free(counter_u64_t c);
void
counter_u64_add(counter_u64_t c, int64_t v);
void
counter_enter();
void
counter_exit();
void
counter_u64_add_protected(counter_u64_t c, int64_t v);
uint64_t
counter_u64_fetch(counter_u64_t c);
void
counter_u64_zero(counter_u64_t c);
#include <sys/sysctl.h>
SYSCTL_COUNTER_U64(parent, nbr, name, access, ptr, descr);
SYSCTL_ADD_COUNTER_U64(ctx, parent, nbr, name, access, ptr, descr);
DESCRIPTION
counter is a generic facility to create counters that can be utilized for any purpose (such as collecting statistical data). A counter is
guaranteed to be lossless when several kernel threads do simultaneous updates. However, counter does not block the calling thread, also no
atomic(9) operations are used for the update, therefore the counters can be used in any non-interrupt context. Moreover, counter has special
optimisations for SMP environments, making counter update faster than simple arithmetic on the global variable. Thus counter is considered
suitable for accounting in the performance-critical code pathes.
counter_u64_alloc(wait)
Allocate a new 64-bit unsigned counter. The wait argument is the malloc(9) wait flag, should be either M_NOWAIT or M_WAITOK. If
M_NOWAIT is specified the operation may fail.
counter_u64_free(c)
Free the previously allocated counter c.
counter_u64_add(c, v)
Add v to c. The KPI does not guarantee any protection from wraparound.
counter_enter()
Enter mode that would allow to safely update several counters via counter_u64_add_protected(). On some machines this expands to
critical(9) section, while on other is a nop. See IMPLEMENTATION DETAILS.
counter_exit()
Exit mode for updating several counters.
counter_u64_add_protected(c, v)
Same as counter_u64_add(), but should be preceded by counter_enter().
counter_u64_fetch(c)
Take a snapshot of counter c. The data obtained is not guaranteed to reflect the real cumulative value for any moment.
counter_u64_zero(c)
Clear the counter c and set it to zero.
SYSCTL_COUNTER_U64(parent, nbr, name, access, ptr, descr)
Declare a static sysctl oid that would represent a counter. The ptr argument should be a pointer to allocated counter_u64_t. A read
of the oid returns value obtained through counter_u64_fetch(). Any write to the oid zeroes it.
SYSCTL_ADD_COUNTER_U64(ctx, parent, nbr, name, access, ptr, descr)
Create a sysctl oid that would represent a counter. The ptr argument should be a pointer to allocated counter_u64_t. A read of the
oid returns value obtained through counter_u64_fetch(). Any write to the oid zeroes it.
IMPLEMENTATION DETAILS
On all architectures counter is implemented using per-CPU data fields that are specially aligned in memory, to avoid inter-CPU bus traffic
due to shared use of the variables between CPUs. These are allocated using UMA_ZONE_PCPU uma(9) zone. The update operation only touches the
field that is private to current CPU. Fetch operation loops through all per-CPU fields and obtains a snapshot sum of all fields.
On amd64 a counter update is implemented as a single instruction without lock semantics, operating on the private data for the current CPU,
which is safe against preemption and interrupts.
On i386 architecture, when machine supports the cmpxchg8 instruction, this instruction is used. The multi-instruction sequence provides the
same guarantees as the amd64 single-instruction implementation.
On some architectures updating a counter require a critical(9) section.
SEE ALSO atomic(9), critical(9), locking(9), malloc(9), sysctl(9), uma(9)HISTORY
The counter facility first appeared in FreeBSD 10.0.
AUTHORS
The counter facility was written by Gleb Smirnoff and Konstantin Belousov.
BSD February 7, 2014 BSD