Dig and concatenate all files yesterday then save it to another directory

Login or Register to Reply

Thread Tools Search this Thread
# 1  
Dig and concatenate all files yesterday then save it to another directory depends on the match

I dont want to use for loop since it is using a lot of resources especially to a thousand files. Wanting to have a while? or something will find files that has been modifed or created yesteraday. View it. And search for soemthing and save it to a certain folder.

for i in `find ./ -mtime -1|grep FILESINEED |head -1`; do VIEWBINARY $i   ; done

I can do that. But if Im gonna do this..

#find ./ -mtime -1|grep FILESINEED |head -3

#for i in `find ./ -mtime -1|grep FILESINEED |head -1`; do VIEWBINARY $i |grep -e COM e -NET -e GOV   > /tmp/$i.log ; done

Expected Output:

It will not save it since the find output

Last edited by invinzin21; 4 Weeks Ago at 05:53 PM.. Reason: To make it more understandable
# 2  
I guess this is an else statement? I need help here. I will have a find and a loop statement. That will look for a file that contains NET in the file and will move it to net directory. Same goes with COM. I can run this 1 by 1 or create 3 commands. But the disadvantage of this. It will run again to the files that already been scan.
# 3  
It is a bit confusing. For example, what is FILESINEED? What is VIEWBINARY?
Perhaps the following puts you on the right track?
for i in `find ./ -mtime -1 | grep FILESINEED`
  case `VIEWBINARY "$i"` in
  ( *COM* ) dest=com;;
  ( *NET* ) dest=net;;
  ( *GOV* ) dest=gov;;
  echo mv "$i" "/tmp/$dest/$i.log"

These 2 Users Gave Thanks to MadeInGermany For This Post:
# 4  
the viebinary could be the string command or any application command that can view a a binary file.
Thank you

--- Post updated at 09:57 PM ---

grep -e COM e -NET -e GOV # this is what im referring to filesineed.

--- Post updated at 10:15 PM ---

Hmmmmm Almost but not quite.. The script will run, after it will search for the file for the

#For the code below, I am hoping example after string $i, i want to grep the file,. I want to know the file if it contains COM or NET or GOV, then it will move it to destination folder. But it did not happen, Also Theres an error as well aside it doesnt search for the thing. Please see below.

for i in `find ./ -mtime -1 |head -30| grep datalog`
  case `string "$i"` in
  ( *COM* ) dest=com;;
  ( *NET* ) dest=net;;
  ( *GOV* ) dest=gov;;
  echo cp "$i" "/tmp/$dest/$i.log"

cp ./59/a8/9dd-225e-005056be5b.datalog /tmp/com/./59/a8/9dd-225e-005056be5b.datalog.log

Last edited by invinzin21; 4 Weeks Ago at 10:32 AM..
Login or Register to Reply

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Save input as text in directory
I am having a little trouble with some things using the code below: 1. printf "Enter variant: "; read variant The user enters the variant and that value is used in the python script. However, I am not sure how to save that value inputed as a text file in a specific directory...... Shell Programming and Scripting
Shell Programming and Scripting
Save files in directory as txt
wget -x -i link.txt The above downloads and create unique entries for the 97 links in the text file. However, each new file is saved as CM080 with a FILE extention. Is there a way to convert each file in that directory to a .txt? The 97 files are in...... Shell Programming and Scripting
Shell Programming and Scripting
Find only files that changed Yesterday
Hi , I know that find / -type f -mtime -1 will show all modified files that changed 24hrs preceeding the time i run the command. This will include list of files that changed today. How do i find only files that changed yesterday staring from 00:00hrs to 23:59? Thanks HG... UNIX for Dummies Questions & Answers
UNIX for Dummies Questions & Answers
I need to back up a bunch of files on a directory and save that file as the current date....
this is what i have to find the files modified within the past 24 hours find . -mtime -1 -type f -print0 | xargs -0 tar rvf "$archive.tar" however i need to save/name this archive as the current date (MM-DD,YYYY.tar.gz) how do i doo this... Shell Programming and Scripting
Shell Programming and Scripting
Checking the directory and concatenate the data of all the log files in that dir
Hi Gurus, I am new to unix and need your help to make a shell script. I have a requirement, would appreciate if you could please help me on it: Requirement: ------------- I will pass 2 parameters in shell script 1). Directory name say errors 2). file extension say .log First of all this...... Shell Programming and Scripting
Shell Programming and Scripting