Sponsored Content
Full Discussion: open files
Top Forums Shell Programming and Scripting open files Post 302504903 by mirni on Tuesday 15th of March 2011 05:56:00 PM
Old 03-15-2011
do a check whether its a dir or regular file, before you open it:

Code:
if [ -d $file ] ; then echo "its a dir" ; fi
if [ -f $file ] ; then echo "its a regular file" ; fi

Also, you got single quotes there, which is probably not what you want. You want "backticks", which is the key next to '1'.
 

10 More Discussions You Might Find Interesting

1. Programming

open ASCII files

Anyone knows how to open an ASCII file by using C Thanks :D (2 Replies)
Discussion started by: Wing m. Cheng
2 Replies

2. UNIX for Advanced & Expert Users

too many files open and questions

Hi all, Presently I'm using a 3pp that uses fopen to open files and I encounter this problem of too many files open when it is trying to open a file. My application is done in java which interfaces with this 3pp. When I instantiate this 3pp it loads up some files but it is pops up the error... (7 Replies)
Discussion started by: lmcanth
7 Replies

3. Solaris

How to check no. of files open currently

I'm getting an error "too many files open" # ulimit -a time(seconds) unlimited file(blocks) unlimited data(kbytes) unlimited stack(kbytes) 8192 coredump(blocks) unlimited nofiles(descriptors) 256 memory(kbytes) unlimited # hard limit shows 1024 I would like to know how many files... (1 Reply)
Discussion started by: max_min
1 Replies

4. UNIX for Advanced & Expert Users

Too Many files open

Hi , We are using a Tool which runs on Unix Server. Have a Event which have some join operation and tries to open files depending on the join operation. So get the error config/variants/orcl6/partitions/ml6/data/ap_PCardMap.csv (Too many open files) Can someone please... (3 Replies)
Discussion started by: shashank_recj
3 Replies

5. OS X (Apple)

Open Files for a process

I am having a client/server application which will download files from server. If server has directories, it will create directories/sub directories and then download files. In this process, I observed that number of open files are more than 400 (which is approxmately same as number of dir/subdir... (1 Reply)
Discussion started by: satyam90
1 Replies

6. Programming

Too many open files - C++ on Unix

Hi all, My requirement is like this: I have list of numbers, i need to get the data related to those numbers from database and write the information into a file . I am using open function to write data related to one number. Close the file. Get the next number ,write data and close again. ... (2 Replies)
Discussion started by: parvathi_rd
2 Replies

7. UNIX for Dummies Questions & Answers

How can i open rar files

Is there a way to open rar files on linux i would really appretiate if u would help :) (2 Replies)
Discussion started by: abu_malek
2 Replies

8. Red Hat

How to open RAR files?

May be this is a newbie question but i want to know hoe to open the RAR file in linux? (1 Reply)
Discussion started by: ashok.g
1 Replies

9. Shell Programming and Scripting

Flagging Open Files

A quick breakdown of my situation: I have 2 servers running OS 10.7, one in the US, the other in China. A folder is being synchronized via EMC's "Syncplicity". Here is my problem- When we open an Excel spreadsheet on one server, Syncplicity does not sync over the temporary file that Excel... (0 Replies)
Discussion started by: sudo
0 Replies

10. Red Hat

Process to use open files

I would like to test open files usage in my system, if I want to create a process ( or script ) that can use a certain amount ( eg. 1000 ) of open files , is it possible to create such process ( or script ) ? (3 Replies)
Discussion started by: ust
3 Replies
fopen(3UCB)					     SunOS/BSD Compatibility Library Functions					       fopen(3UCB)

NAME
fopen, freopen - open a stream SYNOPSIS
/usr/ucb/cc [ flag ... ] file ... #include <stdio.h> FILE *fopen(file, mode) const char *file, *mode; FILE *freopen(file, mode, iop) const char *file, *mode; register FILE *iop; DESCRIPTION
The fopen() function opens the file specified by file and associates a stream with it. If the open succeeds, fopen() returns a pointer to be used to identify the stream in subsequent operations. The file argument points to a character string that contains the name of the file to be opened. The mode argument is a character string having one of the following values: r open for reading w truncate or create for writing a append: open for writing at end of file, or create for writing r+ open for update (reading and writing) w+ truncate or create for update a+ append; open or create for update at EOF The freopen() function opens the file specified by file and associates the stream pointed to by iop with it. The mode argument is used just as in fopen(). The original stream is closed, regardless of whether the open ultimately succeeds. If the open succeeds, freopen() returns the original value of iop. The freopen() function is typically used to attach the preopened streams associated withstdin, stdout, and stderr to other files. When a file is opened for update, both input and output can be performed on the resulting stream. Output cannot be directly followed by input without an intervening fseek(3C) or rewind(3C). Input cannot be directly followed by output without an intervening fseek(3C) or rewind(3C). An input operation that encounters EOF will fail. RETURN VALUES
The fopen() and freopen() functions return a NULL pointer on failure. USAGE
The fopen() and freopen() functions have transitional interfaces for 64-bit file offsets. See lf64(5). SEE ALSO
cc(1B), open(2), fclose(3C), fopen(3C), freopen(3C), fseek(3C), malloc(3C), rewind(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. To support the same number of open files as the system, fopen() must allocate additional memory for data structures using malloc(3C) after 64 files have been opened. This confuses some programs that use their own memory allocators. The fopen() and freopen() functions differ from the standard I/O functions fopen(3C) and freopen(3C). The standard I/O functions distin- guish binary from text files with an additional use of 'b' as part of the mode, enabling portability of fopen(3C) and freopen(3C) beyond SunOS 4.x systems. SunOS 5.11 30 Oct 2007 fopen(3UCB)
All times are GMT -4. The time now is 01:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy