06-11-2009
is this what you want...
Quote:
Originally Posted by
spkandy
<Sample Code>
FILE_COUNT=`echo "${SOURCE_FILE}" | tr '|' '\n' | wc -l
COUNTER=1
while [ ${COUNTER} -le ${FILE_COUNT} ]
do
FILE=`echo ${SOURCE_FILE} | cut -d '|' -f${COUNTER}`
<FTP Function>
if [[ ${COUNTER} = ${FILE_COUNT} ]]
then
mv $FILE <Target Directory>
fi
(( COUNTER = COUNTER + 1 ))
done
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am trying to process error files in selected directories. I can count the files that are there and export the contents to a file for either emailing or printing. The next step is to move the files to a processed directory with the name changed to .fixed as the last extension.
for file in... (2 Replies)
Discussion started by: jagannatha
2 Replies
2. Shell Programming and Scripting
Hello,
I have a question regarding file naming under a loop in tcsh. I have the following code:
#!/bin/tcsh
foreach file (test/ProteinDirectory/*) # The * is a bunch of ProteinFile1, ProteinFile2, ProteinFile3, etc.
sh /bioinfo/home/dgendoo/THREADER/pGenThreader.sh $file $file
... (4 Replies)
Discussion started by: InfoSeeker
4 Replies
3. Shell Programming and Scripting
Simple enough problem I think, I just can't seem to get it right.
The below doesn't work as intended, it's just a function defined in a much larger script:
CheckValues() {
for field in \
Group_ID \
Group_Title \
Rule_ID \
Rule_Severity \
... (2 Replies)
Discussion started by: Vryali
2 Replies
4. Shell Programming and Scripting
i=0
while
do
sizesfor0=`cat 16 | grep 'pickSize' -A 1 | grep '_sz' | cut -d'_' -f1`
sizesfor0=${sizesfor0//id=\"lll/:}
IFS=: array0=( $sizesfor0 )
echo ${array0}
i=$(( $i + 1 ))
done
So, right now I have two variables in the while statement above
sizesfor0 and array0
The... (1 Reply)
Discussion started by: phpchick
1 Replies
5. Shell Programming and Scripting
OS : RHEL 6.1
Shell : Bash
I have lots of files in /tmp/stage directory as show below.
Using a loop, I need to print all the filenames in this directory except those ending with a number. How can I do this ?
# pwd
/tmp/stage
#
#
# ls -l *
-rw-r--r--. 1 root root 0 Oct 7 18:38 stmt1... (2 Replies)
Discussion started by: kraljic
2 Replies
6. UNIX for Dummies Questions & Answers
Hi Fellows,
I was wondering how I can remove first few characters from multiple file names without do loop in unix?
e.g.
water123.xyz
water456.xyz
to
123.xyz
456.xyz
Thanks
Paul
Thanks. (3 Replies)
Discussion started by: Paul Moghadam
3 Replies
7. Shell Programming and Scripting
I'm trying to grab a list of file names from a directory, then process those files 5 at a time. In the link below. Instead of using files I'm using the files array which contains 15 strings starting with AAA.
So I'm trying to assign $fileset 5 of the strings at a time to pass to a command. So... (4 Replies)
Discussion started by: zBernie
4 Replies
8. Shell Programming and Scripting
Hi, I have a control file which will contain all filenames(300) files. Loop through all the file names in the control files and check the existence of this file in another directory(same server). I need to infinitely(2 hrs) run this while loop until all the files are found. Once a file is found,... (5 Replies)
Discussion started by: laknar
5 Replies
9. Programming
Hi guys
I'm a beginner in fortran. So excuse me for my naivety, let me briefly describe what I was trying to do. I have let's say 2 files named reac-1 and reac-2. After opening these files I've to do some calculations, close these files and open the same files again in a loop. So my faulty code... (6 Replies)
Discussion started by: saleheen
6 Replies
10. Shell Programming and Scripting
As part of a bash the below line strips off a numerical prefix from directory 1 to search for in directory 2.
for file in /home/cmccabe/Desktop/comparison/missing/*.txt
do
file1=${file##*/} # Strip off directory
getprefix=${file1%%_*.txt}
... (5 Replies)
Discussion started by: cmccabe
5 Replies
LEARN ABOUT FREEBSD
counter_u64_add
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