06-18-2009
Hi ,
use readdir and file test operations .
readdir -- will give you all the contents of your present working directory in array format.
to select the directories from that array use file test operators.
Regards,
Penchal.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello All,
A part of my very basic perl code requires me to read a single value from a text file.
The file output is the following:
Reading image ... done
IMAGEREGION=0x0x0-256x162x256
VOXELDIMENSION=0.9375000000x1.2000000477x0.9375000000
VOXELNUMBER=10527001... (7 Replies)
Discussion started by: ncl
7 Replies
2. Shell Programming and Scripting
Hi,
I have a piece of code as follows:
i=0
while read LINE
do
var = "$LINE"
i=$((i+1))
echo "${var}"
done < file
I want to assign value to the array var.
However, when i execute the script i get a error.
Please can you help me know what i am missing.
I ultimately want to... (2 Replies)
Discussion started by: sunrexstar
2 Replies
3. Shell Programming and Scripting
Hi,
I have requirement to assign values to variables which are created dynamically.
Below is the code which i am using to achieve above requirement.
#!/bin/ksh
oIFS="$IFS"; IFS=','
STR_FAIL_PARENT_IF_FAILS="WF_F_P_IF_FAILS1,WF_F_P_IF_FAILS2,WF_F_P_IF_FAILS3"
set -A... (1 Reply)
Discussion started by: tmalik79
1 Replies
4. Shell Programming and Scripting
I have an array and two variables as below,
I need to check if $datevar is present in $filename.
If so, i need to replace $filename with the values in the array.
I need the output inside an ARRAY
How can this be done.
Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies
5. Shell Programming and Scripting
Hello Guru's
I want to read an array into a flatfile
Please let me know how to do the same
So far this the below code
use strict;
use warnings;
open (my $data , '<', $ARGV)|| die "could not open $ARGV:\n$!";
my @array=(<$data>);
my @sorted=sort... (8 Replies)
Discussion started by: Pratik4891
8 Replies
6. UNIX and Linux Applications
Hi,
I want the Perl script with versions 5.8.2 and 5.8.5 starting with
#!/usr/bin/perl
The Perl program should read the excel file or text file line by line and taking into an array and search in the UNIX directories for reference file of .jsp or .js or .xsl with path .The Object names... (2 Replies)
Discussion started by: pasam
2 Replies
7. Shell Programming and Scripting
Hello All,
Can you please help me with the below.
#!/bin/bash
ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5 EXTRACT_DT:30-SEP-12 VER_NUM:1"
ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5... (14 Replies)
Discussion started by: Ariean
14 Replies
8. Solaris
I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
Discussion started by: blinkingdan
1 Replies
9. UNIX for Beginners Questions & Answers
i have this basic code that i wrote to read a file and place it's values to an array. the source/input file will have multiple strings on it that is separated by a whitespace.
sample_list.txt file contents:
ACCT1 TABLE1
ACCT2 TABLE2
ACCT3 TABLE3
script file: sample_list.sh
... (3 Replies)
Discussion started by: wtolentino
3 Replies
LEARN ABOUT OPENSOLARIS
scandir
scandir(3UCB) SunOS/BSD Compatibility Library Functions scandir(3UCB)
NAME
scandir, alphasort - scan a directory
SYNOPSIS
/usr/ucb/cc [ flag... ] file...
#include <sys/types.h>
#include <sys/dir.h>
int scandir(dirname, namelist, select, dcomp)
char *dirname;
struct direct *(*namelist[]);
int (*select(), (*dcomp)();
int alphasort(d1, d2)
struct direct **d1, **d2;
DESCRIPTION
The scandir() function reads the directory dirname and builds an array of pointers to directory entries using malloc(3C). The second param-
eter is a pointer to an array of structure pointers. The third parameter is a pointer to a routine which is called with a pointer to a
directory entry and should return a non zero value if the directory entry should be included in the array. If this pointer is NULL, then
all the directory entries will be included. The last argument is a pointer to a routine which is passed to qsort(3C), which sorts the com-
pleted array. If this pointer is NULL, the array is not sorted.
The alphasort() function sorts the array alphabetically.
RETURN VALUES
The scandir() function returns the number of entries in the array and a pointer to the array through the parameter namelist. The scandir()
function returns -1 if the directory cannot be opened for reading or if malloc(3C) cannot allocate enough memory to hold all the data
structures.
The alphasort() function returns an integer greater than, equal to, or less than 0 if the directory entry name pointed to by d1 is greater
than, equal to, or less than the directory entry name pointed to by d2.
USAGE
The scandir() and alphasort() functions have transitional interfaces for 64-bit file offsets. See lf64(5).
SEE ALSO
cc(1B), getdents(2), malloc(3C), qsort(3C), readdir(3UCB), readdir(3C), lf64(5)
NOTES
Use of these functions should be restricted to applications written on BSD platforms. Use of these functions with any of the system
libraries or in multithreaded applications is unsupported.
SunOS 5.11 30 Oct 2007 scandir(3UCB)