I want to read a constantly changing file and do some operation on text found in that file.
Actually that is log file of linux system and whenever i find a matching string in that file i want to create a text file with timestamp. is it possible to read that file?
here is sample output of log file
I want to create a file whenever "New USB device found" text is found in this file. create a file with timestamp in \usr\temp folder.
You can get the information directly from the source by creating a custom udev rule. You can use them to run simple commands whenever a device is detected. See man udev for details and examples, and also check out the udev rules your system already has ( which do things like populate /dev/disk/by-path/ ) which may be under /etc/udev.d/ or /lib/udev/rules.d/
On my system, custom rules are kept in /etc/udev.d/ while system ones are kept in /lib/udev/rules.d/
@ Corona688: thanks for reply. but in my case i can't use udev as it is not allowed to be dependent on it. for me there are 2 ways to check it. one write perl code ( which I can't as I know nothing about perl). 2nd use bash scripting (which i'm trying to do)
Last edited by kashif.live; 04-14-2012 at 05:59 PM..
@Scrutinizer: sorry, you didn't get my point.
I know tail -f or tailf can be used to read from some file but i want to put that thing in if condition.
like keep reading this file and when u get string "USB connected". do some action. Now I'm getting problem while using this command in if condition.
@Scrutinizer: can you please explain what is "IFS" in this loop.is it the string that I'm trying to search? and why i need text.out? can't i go without it? and sorry If my question wasn't clear enough.
simply, I just need a way to keep a check all the time on a log file so that whenever some specific text comes into that file, i get alert regarding that text. any function call? or any loop, condition? any way in scripting?
Linux Redhat, BASH Shell.
I want to put this in my .bash_profile
I have log files that go to directory paths based in part on other variables such as went DB Name is set in memory. So if the DB Name changes the path to the log file changes. How do I create an environment variable I put into... (6 Replies)
I have the following piece of code. Currently the command line arguments are passed as shown below using the "= "sign. I capture the name of the argument, for example vmod and it's corresponding user parameter which is jcdint-z30.cmd.
./raytrac vmod=jcdint-z30.cmd srFile=jcdint.sr
Now I want... (12 Replies)
Hi
my requriment is read the file name dynamically my code is
#!/bin/sh
file="/c/work/loan/"
Header_Trailer_move()
{
sed '1d;$d' $file| cat >sam.txt
}
Header_Trailer_move
in above given path my list of files or there i have to read file dyanamically when i entered particular file name... (2 Replies)
Hi All
At the moment the following code works but ideally i do not want to have to change the original $1
tr "\r" "\n" < "$1" > "$1.fix"
printf "\n" >> "$1.fix"
mv "$1.fix" "$1"
FILE=$1
coffee_out="splitmovie"
coffee_fill="-splitAt"
coffee_end="-self-contained -o output.mov $2"... (1 Reply)
Hello everyone I recently clone a system and doing so it gave my nics cards id's of eth3 and eth4 instead of eth0 and eth1. Is there a config file or something out there where I can change these back? All help will be appreciated. (2 Replies)
I have a directory with its subdirectories and files. I want to change them all to read only. Say it is ~/test
chmod -R 444 ~/test
chmod: `/home/myname/test': permission denied
I do not understand. Do I have to have executable mode for a diirectory to access.
How can I change ~/test to... (5 Replies)
Hey,
First of all I want to know How do I see the atime of a file ?? Whats the command ??
I think ls -l shows the last modified time right ? Because when I use cat to read a file, the timestamp shown by ls -l does not change.
Its not ls -lu ! man ls did not help ! How do I see the last... (8 Replies)
I have a tab delimited file which has 27 character fields. The file needs to be loaded into an Oracle table. But the challenge is that everytime the file comes it may or may not have values in all 27 fields.
Column Definition of the 27 fields:
TYPE: Char (1)
NAME: Char (30)
CUSTOM_VAL: Char... (8 Replies)