Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Creating a list of files in directory? Post 302375255 by f_o_555 on Friday 27th of November 2009 05:21:01 AM
Old 11-27-2009
This something I wrote that does the job, but there may be a smarter way

Code:
for I in `ls ${PATH}/*.out | cut -c${LENGTH}-`;
do
 ARRAY[$COUNTER]=$I
 if [ $COUNTER -lt 10 ]; then
     LIST[$COUNTER]=000$COUNTER
 else
     if [ $COUNTER -lt 100 ]; then
         LIST[$COUNTER]=00$COUNTER
     else
         if [ $COUNTER -lt 1000 ]; then
              LIST[$COUNTER]=0$COUNTER
         else
             if [ $COUNTER -lt 10000 ]; then
                  LIST[$COUNTER]=$COUNTER
             fi
         fi
     fi
 fi

 

10 More Discussions You Might Find Interesting

1. Programming

creating object files in a specific directory

hello, i have a makefile in which i am specifying the option for creating the object files of the source files. The option which i am using is this : gcc -c main.c first.c by default these object files are created in the same directory in which the makefile is present. what option... (1 Reply)
Discussion started by: svh
1 Replies

2. UNIX for Dummies Questions & Answers

extract tar files without creating directory

I received a tar file of a directory with 50,000 files in it. Is it possible to extract the files in the tar file without first creating the directory? ie. Doing tar -xvf filename.tar extracts as follows: x directory/file1.txt x directory/file2.txt . . . I would like to avoid... (4 Replies)
Discussion started by: here2learn
4 Replies

3. Shell Programming and Scripting

ls > file - Creating file containing the list of all files present in a directory

Hi All, I need to create a file which contains the list of all the files present in that directory. e.g., ls /export/home/user/*.dat > list_file.dat but what i am getting is: $ ls /export/home/user/*.dat > list_file.dat /export/home/user/*.dat: No such file or directory But I have... (1 Reply)
Discussion started by: pranavagarwal
1 Replies

4. Shell Programming and Scripting

Creating date directory and moving files into that directory

I have list of files named file_username_051208_025233.log. Here 051208 is the date and 025233 is the time.I have to run thousands of files daily.I want to put all the files depending on the date of running into a date directory.Suppose if we run files today they should put into 05:Dec:08... (3 Replies)
Discussion started by: ravi030
3 Replies

5. UNIX for Dummies Questions & Answers

Creating a List of Files With Find

Hi, I need to go through all the files on my system and build a list/output file with the paths of all files where the first two characters within the file match an expression. I know I can use something like find . | xargs cut -b1-2 or find . -exec cut -b1-2 {} \; to get the characters... (3 Replies)
Discussion started by: 008_
3 Replies

6. UNIX for Dummies Questions & Answers

Creating a file to count how many files in the directory

hello there i want to creat a file that count how many files i have in the directory. for this i use the command find . -type f | wc -l > 1In1.myfile the problem with this command is that it not update after i add a new file in the directory. Anyone got any ideas how i can... (5 Replies)
Discussion started by: AntiPin
5 Replies

7. UNIX for Dummies Questions & Answers

help creating gzip of directory files via cron

**BTW- very new to scripting** I have created a shell script to gzip the public_html files on our website. I have tested this script on another directory on our site and it worked, but when I replaced the directory with the public_html directory it failed. I am executing this script via a... (7 Replies)
Discussion started by: alblue
7 Replies

8. Programming

Script for creating a directory & move the .tif files in it.

Hi Team, I have thousands of TIF files which are converted from PDF. Below is a sample of it. LH9406_BLANCARAMOS_2012041812103210320001.tif LH9406_BLANCARAMOS_2012041812103210320002.tif LH9406_BLANCARAMOS_2012041812103210320003.tif LH9411_ANGENIAHUTCHINSON_2012041812102510250001.tif... (9 Replies)
Discussion started by: paragnehete
9 Replies

9. Shell Programming and Scripting

Creating a list of files retrieved from MGET

Is there a way to create a txt file with the names of the files I retreive using mget *.file. I want to use this file as input to a delete command. Using HP-UX (3 Replies)
Discussion started by: jagf
3 Replies

10. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies
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
All times are GMT -4. The time now is 11:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy