![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to search and replace text in same file | Vrgurav | Shell Programming and Scripting | 1 | 04-25-2008 03:20 AM |
| Shell script to search for text in a file and copy file | imeadows | UNIX for Dummies Questions & Answers | 8 | 04-20-2008 01:41 PM |
| How to search for text within compressed file | HLee1981 | UNIX for Advanced & Expert Users | 8 | 09-06-2007 03:50 AM |
| Search file contain some text | yuimyt | UNIX for Dummies Questions & Answers | 5 | 05-22-2006 01:31 PM |
| To search for a text in until i find that | kotasateesh | Shell Programming and Scripting | 3 | 08-30-2005 05:32 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
find file with date and recursive search for a text
Hey Guyz I have a requirement something like this..
a part of file name, date of modification of that file and a text is entered as input. like Date : 080206 (MMDDYY format.) filename : hotel_rates text : Jim now the file hotel_rates.ZZZ.123 (creation date is Aug 02 2006) should be found first and then the file should be opened in a read olny mode pointing to the first occurance of text 'Jim' in that file. when we press 'n' the next occurance of Jim should be visible and so on until the EOF. once searching Jim is done when we press q the control should be back to program. all the files will be located in an archive folder with name /archive and there'll be files with different dates like hote_rates.XXX.333 Aug 01 2006 hotel_rates.YYY.222 Jul 30 2006 hotel_rates.ZZZ.123 Aug 02 2006 logistic_rates.ZZZ.123 logistic_rates.SSS.134 Now for the above example the file hotel_rates.ZZZ.123 should be found and it should be pinting to first occurance of Jim in that file after the user enters the input and hits enter. Let me know if I made myself clear here.. Thanks, Ronnie |
| Forum Sponsor | ||
|
|
|
|||
|
Not a homwork
Hi Tayyab,
This is not a home work question. I started working in Unix just 6 months back. We have a daily synchronization of information with-in the internal systems of our company. like we recieve files like hotel_rates.ZZZ and once we post this data to database the file is stored in archive folder as (with a random 3 digit extention) hotel_rates.ZZZ.123 and once this file is pushed to archive folder there is no chance of modification. some times we might need to look up some information in these files which we posted, so This coding is a part of that. We would need to retrieve the file with mtime. so according to your notes, If we take the input as Aug 02 2006 would be better rather than 080206 right ? let me know how to track the file and open it in readonly mode for recursive search (can we use 'less' in the shell script?) |
|
|||
|
i did this
hey I did this..
find . -name \*hotel_rates.* | xargs ls -lt | grep "Aug 02 2006" this gives me .. -rw-rw-r-- 1 user group 1025 Aug 02 2006 ./hotel_rates.ZZZ.147 can some one tell me how do I cut the file name from this line plz ??? |
|
|||
|
question
hey how do we open a file and point it to a text/string we are searching..
for eg. we are searching for a string 'Jim' in file xxx.txt in a shell program we have to open this file in read only mode and point it to first occurance of 'Jim' like we do 'less xx.txt' and then type '/Jim' to find the occurance;... |
|||
| Google The UNIX and Linux Forums |
| Tags |
| mtime |
| Thread Tools | |
| Display Modes | |
|
|