1.The value of the variable a holds something like
Quote:
-rw-r--r-- 1 ondesk staging 155 Oct 8 03:17 some.txt
. So when u try to change directory (cd $a) the shell will be unable to do so and throws the above error.Hence try to give the correct directory name to cd
2.Also make sure the argument to cd is given as absolute path (if changing to different directory)
Quote:
grep: can't open THerrFile_2.err
Make sure above such file exist in the current working dir. i.e where you have saved/run this shell script.Else specify the correct path.
drwxrwsr-x 2 tia uniqgrp 12288 10 Oct 00:30 CSB.Oct10_00:01/
i need to get only the directory name i.e CSB.Oct10_00:01 part but not the entire line.
please advice.
---------- Post updated at 09:55 AM ---------- Previous update was at 08:38 AM ----------
Hi,
in the above code for variable a i am getting a directory name.
but in "Cd $a" it is not going into the directory.
because i am getting the below errors.
}
grep: can't open THerrFile_1.err
grep: can't open THerrFile_2.err
grep: can't open THerrFile_3.err
grep: can't open THerrFile_4.err
grep: can't open THerrFile_5.err
Please advice if the above code is correct or i am going wrong some where.
1.It wud have been better if you have posted the value of a. Looking the above code seems like var a is not executed.Try as below as prev said..
Do not use those single quotes- ' '
2. Before grep'ing the file THerrFile_*.err take sometime to check if that file exist in your current working dir or where this script is stored.As the error states
Quote:
grep: can't open THerrFile_1.err
- there is no such file in the current dir.
This User Gave Thanks to michaelrozar17 For This Post:
once the cd command is executed then i can grep the files in the directory.As the directory is not changing i am not able to grep and it says can't open the THerrFile_2.err file.
the value of a will be like CSB.Oct11_17:30.
it is not working .
please help.
-------
It is working fine now.
I am copying the final code.hope it may help some one.
the code that i pasted in my previous posts works fine ,if all files are existing.if any file is missing it is comming out.
but my requirement is,it should go to next file and grep the ora-messages.
i am copying my code also.
for example if we couldn't find THerrFile_1.err file in the directory.it is comming out,it should go to
THerrFile_2.err ,THerrFile_3.err ,THerrFile_4.err ,THerrFile_5.err files and pick the ora-messages.
I am trying to fetch the latest modified file from a directory using the command
find . -type f -exec ls -lt \{\} \+ | head | awk '{print $9}'
After the O/P, I get the below mentioned error and the command doesnt terminate at all.
find: ls terminated by signal 13
find: ls terminated by... (2 Replies)
I wan to pick the latest modified file name and redirect it to a file ..
ls -tr | tail -1 >file
but this is printing file ins side the filename ,
can anyone help me out (5 Replies)
I have a few log files which get generated on a daily basis..So, I need to pick only the ones which get generated for that particular day.
-rw-r--r-- 1 staff 510732676 Apr 7 22:01 test.log040711
-rwxrwxrwx 1 staff 2147482545 Apr 7 21:30 test.log.2
-rwxrwxrwx 1 staff 2147482581 Apr 7 19:26... (43 Replies)
I want to get the latest files from multiple directories, d1, d2,d3 and d4 under the parent dierectoy d.
can anyone help out with this?
thx (3 Replies)
Hi,
I have some list of directories in the form datemonthyear e.g. 02082009, 03082009 and 04082009 etc.
I need to pick the latest directory from the current working directory.
Outcome:
05082009
This is the output am expecting.
Thanks (6 Replies)
in the below .. i want to pick the latest logfile which is having JPS.PR inside..
that means i want particularly "spgport040408041223.log:@@@@@@@@ 04:13:09 Adding: JPS.PR."
which is latest among these..
is it possible to compare the current time with logfile time ?
reptm@xblr0758rop>... (4 Replies)
I have task in which I need to pickup a set of files from a directory
depending on the following criteria:
Every month 6 files are expected to arrive at /test.
The files come with date timestamp and the latest file set for the month needs to be used
Suppose this is the set of files that present... (5 Replies)
i have a directory in which there are executable files and these files are added at runtime. now i need a shell script which will be called at a certain interval. this shell script should find the latest executable file in that directory and start that executable. care should be taken that once the... (6 Replies)