Capture listed files from find command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capture listed files from find command
# 8  
Old 01-17-2013
Quote:
Originally Posted by ashly
Hi Ranga,

I tried but I got the error below:
PHP Code:
sed0602-404 Function s/^/'[2013-01-17 cannot be parsed. 
Can you show your full command....?
# 9  
Old 01-17-2013
Quote:
Originally Posted by rangarasan
Can you show your full command....?
Hi Ranga,

Full code as below:
Code:
#!/bin/ksh

LogPath=/usr
LogFile=achieve.log

InputPath=/usr/temp

echo [`date +"%Y-%m-%d %T"`] "---------------" | tee -a $LogPath/$LogFile
find $InputPath -type f -mtime +30 | sed "s/^/'[`date +"%Y-%m-%d %T"`]/" | tee -a $LogPath/$LogFile
echo [`date +"%Y-%m-%d %T"`] "---------------" | tee -a $LogPath/$LogFile

# 10  
Old 01-17-2013
Quote:
Originally Posted by ashly
Hi Ranga,

Full code as below:
Code:
#!/bin/ksh

LogPath=/usr
LogFile=achieve.log

InputPath=/usr/temp

echo [`date +"%Y-%m-%d %T"`] "---------------" | tee -a $LogPath/$LogFile
find $InputPath -type f -mtime +30 | sed "s/^/'[`date +"%Y-%m-%d %T"`]/" | tee -a $LogPath/$LogFile
echo [`date +"%Y-%m-%d %T"`] "---------------" | tee -a $LogPath/$LogFile

Please remove the extra single quote(').

Cheers,
RangaSmilie
# 11  
Old 01-17-2013
Quote:
Originally Posted by rangarasan
Please remove the extra single quote(').

Cheers,
RangaSmilie
Hi Ranga,

I removed the extra single quote. But error still occurred:
PHP Code:
[2013-01-17 17:47:55] ---------------
./
ArchiveFile_01.sh[9]: ]/:  not found.
sed0602-404 Function s/^/[2013-01-17 cannot be parsed.
[
2013-01-17 17:47:55] --------------- 
# 12  
Old 01-17-2013
Try
Code:
$ DT=$(date +"%Y-%m-%d %T")
$ find . -printf "[$DT]%f\n"
[2013-01-17 11:15:26].
[2013-01-17 11:15:26]list
.
.
.

# 13  
Old 01-17-2013
Hi guys,

I attached 2 codes and 2 outputs as below:

Code 1:
Code:
find $InputPath -type f -mtime +40 | sed "s/^/[`date +'"'%Y-%m-%d %T'"'`] /" | tee -a $LogPath/$LogFile

Output 1:
PHP Code:
[""2013-01-18 08:56:17""filename1
[""2013-01-18 08:56:17""filename2 
Code 2:
Code:
DateStr=[`date +"%Y-%m-%d %T"`]
find $InputPath -type f -mtime +40 | sed "s/^/$DateStr /" | tee -a $LogPath/$LogFile

Output 2:
PHP Code:
[2013-01-18 08:53:14filename1
[2013-01-18 08:53:14filename2 
Just wonder how to get rid of the double quotes in the output 1 by using code 1.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete files listed in text file

Hi Team, Here's the scenario, I have a text file called "file_list.txt". Its content is as follows. 111.tmp 112.tmp 113.tmp 114.tmp These files will present in "workdir" directory. It has many files. But only the files present in file_list.txt has to be deleted from the workdir... (7 Replies)
Discussion started by: kmanivan82
7 Replies

2. Shell Programming and Scripting

Total number of files in the folder should be listed

Hi All, When i give the ls -lrt to list out all files with total number of files , i get the output as ls -lrt total 72 -rw-r--r-- 1 hari staff 796 Jul 11 09:17 va.txt -rw-r--r-- 1 hari staff 169 Jul 13 00:20 a.log -rwxr-xr-x 1 hari staff 659 Aug... (9 Replies)
Discussion started by: Kalaihari
9 Replies

3. Shell Programming and Scripting

Copy files listed in text file to new directory

I am trying to write a script that will copy all file listed in a text file (100s of file names) to a new directory Assume script will run with main as current working directory and I know how many files/lines will be in List.txt Im trying to work up a test script using this model Contents of... (2 Replies)
Discussion started by: IAmTheGrass
2 Replies

4. Shell Programming and Scripting

How to read a file name that was recently edited when listed using ls command?

I was trying to write a script that will process recently creatd file. From below, the script should process input_20111230.dat file. sam:/top/work/data/input: ls -ltr input_*.dat -rw-rw-rw- 1 work edprod 455668 Dec 24 09:16 input_20111224.dat -rw-r--r-- 1 work edprod ... (7 Replies)
Discussion started by: siteregsam
7 Replies

5. Shell Programming and Scripting

Files copying - [ Listed files alone. ] - Shell script

Hi All, I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files. To Do From Directory : /myproject/MainDir To Directory : /myproject/data List of files need to copy is in the file: /myproject/filesList.txt ... (4 Replies)
Discussion started by: linuxadmin
4 Replies

6. Shell Programming and Scripting

Cut the first column in listed files

1.give the command wc -l *e* > create2.txt 2.now create2.txt contains a.txt b.txt c.txt d.txt 3.create2.txt is a random file ( output may vary depends on time) (eg: a1.txt , b1.txt,c1.txt,d1.txt if time changes) 4. now i want to cut the first colum from all the files mentioned in... (12 Replies)
Discussion started by: adaleru
12 Replies

7. Shell Programming and Scripting

Cut the first column in listed files > PERL script

Hi All, Using this command wc -l *e* > create2.txt i'm getting the following output >>>create2.txt listed output files, my requirement is how to cut the first coloum in all the files mentioned in create2.txt in perl. 50 allignment.pl 3 create.txt 4 application.txt ... (8 Replies)
Discussion started by: adaleru
8 Replies

8. Shell Programming and Scripting

Copy files listed in a text file - whitespace problem.

Hi, Say I have this text file <copy.out> that contains a list of files/directories to be copied out to a different location. $ more copy.out dir1/file1 dir1/file2 dir1/file3 "dir1/white space" dir1/file4 If I do the following: $copy=`more copy.out` $echo $copy dir1/file1... (4 Replies)
Discussion started by: 60doses
4 Replies

9. Shell Programming and Scripting

Little bit weired : Find files in UNIX w/o using find or where command

Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same. Thanks in advance. Regards Jatin Jain (10 Replies)
Discussion started by: jatin.jain
10 Replies

10. HP-UX

CVSWeb - Directories listed but files not listed

I am using CVSWeb on HPUnix. When i access it, all directories are listed but files are not listed. I am getting the error "NOTE: There are 51 files, but none matches the current tag. " in tomcat sevrer log i am getting the message "rlog warning: Missing revision or branch number after -r"... (0 Replies)
Discussion started by: ganesh
0 Replies
Login or Register to Ask a Question