Sponsored Content
Full Discussion: File existence and increment
Top Forums Shell Programming and Scripting File existence and increment Post 302441957 by ultimatix on Tuesday 3rd of August 2010 03:28:09 AM
Old 08-03-2010
Bug File existence and increment

Code:
 
count=0;
while read line;
 do [[ -e "$line" ]] && let  count=count+1; done < file_name.txt
 echo
 echo "$count of 10  files found "
 echo

The scenario is a follows :
I have a file which contains a list of filenames present in particular directory .
I am checking fo the existence of the file and incrementing the counter by 1.
Now there are some files which are of a previous date ( but as the file name is same , it passes my check )
So what i plan to do is

store
Code:
 
ls -lrt file_name | awk {'print$7'}

in a varibale
store
Code:
 
date +'%d'

in a variable and compare both , if they dont match thn don't increment the counter .

Please advise.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File existence

Hey all, I have total new with shell scripting so I don't know if what I need to do even possible, here it is...for a duration of time (say...1 hour) I need to check for the existence of a particular file, if it exists then I will invoke a java program or I will continue to check until a)... (2 Replies)
Discussion started by: mpang_
2 Replies

2. UNIX for Dummies Questions & Answers

File existence problem

I have a problem with file existence in shell. that is the code.. #!/bin/sh if then echo "File Exist!!" else echo "Error" fi but it gives an error in 2nd line. Did i write example.txt wrong? Is there any (`) or (") missing? or something like that? (2 Replies)
Discussion started by: anormal
2 Replies

3. Shell Programming and Scripting

Checking the existence of a file..

Hi, I am trying to check for the existence of a file using the 'test' and the file existence options. When trying to check for a file with a space in between e.g 'Team List', it gives the following error. learn1: line 3: test: `Team: binary operator expected I am pasting my code below as... (7 Replies)
Discussion started by: igandu
7 Replies

4. Shell Programming and Scripting

File existence using ls

Hi I want to check a particular file is available or not. But i know only the pattern of that file sat AB1234*.txt.I need the latest file name and it ll be used in the script. How can i do this using ls -ltr command. Thanks, LathishSundar V (2 Replies)
Discussion started by: lathish
2 Replies

5. AIX

Check for File Existence

I have requirement where i need to search for files which start with SALESORDER and PURCHASEORDER. i need to process the files with SALESORDER first and then PURCHASEORDER. If SALESORDER files are not there i dont want to process PURCHASEORDER and i want to come out of script. I have written a code... (4 Replies)
Discussion started by: dsdev_123
4 Replies

6. Shell Programming and Scripting

Parse file from remote server to calculate count of string existence in that file

Hi I need to parse the file of same name which exist on different servers and calculate the count of string existed in both files. Say a file abc.log exist on 2 servers. I want to search for string "test" on both files and calculate the total count of search string's existence. For... (6 Replies)
Discussion started by: poweroflinux
6 Replies

7. UNIX for Dummies Questions & Answers

To check for existence of a file

I need to check for the existence of a file *.log in a specific directory using a perl script. Presently am not in that particular directory. So i am using chdir ("/path/to/my/file) And then i am using the -e in an if statement to check if it exists. if (-e $File) {......} $File contains the... (1 Reply)
Discussion started by: manutd
1 Replies

8. Shell Programming and Scripting

File existence

Hi I'm using the below command in shell script to check for file exists in the path if ..... fi path and test are variables path and the file exists but the commands inside if condition is executed (! operator used) Is the above way of checking for file existence is correct? ... (4 Replies)
Discussion started by: vinoth_kumar
4 Replies

9. Shell Programming and Scripting

Script to check for the file existence, if file exists it should echo the no of modified days

Hi, I am looking for a shell script with the following. 1. It should check whether a particular file exists in a location #!/bin/sh if ; then echo "xxx.txt File Exists" else echo "File Not Found" fi 2. If file exists, it should check for the modified date and run a command... (2 Replies)
Discussion started by: karthikeyan_mac
2 Replies

10. Shell Programming and Scripting

File existence

Hope someone can help me on this In a directory ,files are dynamically generated.I need a script to do the following if files are not received for more than 2 hours or if the received file is empty then do something How can I put that in a script.Thank you eg. in cd /dir_name the... (13 Replies)
Discussion started by: haadiya
13 Replies
READ(5) 							File Formats Manual							   READ(5)

NAME
read, write - transfer data from and to a file SYNOPSIS
Tread tag[2] fid[2] offset[8] count[2] Rread tag[2] fid[2] count[2] pad[1] data[count] Twrite tag[2] fid[2] offset[8] count[2] pad[1] data[count] Rwrite tag[2] fid[2] count[2] DESCRIPTION
The read request asks for count bytes of data from the file identified by fid, which must be opened for reading, starting offset bytes after the beginning of the file. Count must be less than or equal to MAXFDATA (8192, defined in <fcall.h>). The bytes are returned with the read reply message. The count field in the reply indicates the number of bytes returned. This may be less than the requested amount. If the offset field is greater than the number of bytes in the file, a count of zero will be returned. For directories, read returns an integral number of direc- tory entries exactly as in stat (see stat(5)), one for each member of the directory. The read request message must have offset and count zero modulo DIRLEN. The write request asks that count bytes of data be recorded in the file identified by fid, which must be opened for writing, starting off- set bytes after the beginning of the file. If the file has been opened append only, the data will be placed at the end of the file regard- less of offset. Directories may not be written. The write reply records the number of bytes actually written. It is usually an error if this is not the same as requested. ENTRY POINTS
Read and write messages are generated by the corresponding calls. Because of the MAXFDATA limit, more than one message may be produced by a single call. READ(5)
All times are GMT -4. The time now is 02:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy