I want to locate a string 'Local=IN' from a file and I am sure that this string is located within 100 lines(assumptio n) from the beginning of the file out of 5000 lines. The 100th line start with the word '--Begin'. So in order to locate the string from only 100 line, I think copying all the file content into any array is not a good idea.
I want the grep command to exist in the script.
I have the following code. I need...
User Profile
Collapse
-
Find the string using grep command from the huge data fil
-
powerfulperl started a topic How To write the content in a different file (i.e temp file)and then rename it to thin PerlHow To write the content in a different file (i.e temp file)and then rename it to th
I have the following code, I need to write the content of a file.txt after searching
for line Local=IN, if found then its o.k if not found then enter the line Local=IN after
the line 'Testing Option OK'.
1. open FH, "<file.txt" ;
2. $/=undef; #set slurp mode
3. $file_contents= <FH>;
4. if (index($file_co ntents, "Local=IN") !=-1) { # file doesn't... -
powerfulperl replied to Search for a particular line from a file and paste it in all the other filesin PerlDude I know what I wanted, I have gone through the code but there seems to be problem with the existing code of mine. I just need a true programmer who can guide me in sorting out my problem rather than wasting time by giving other site links.
If you can help then plz assist me. -
Enter data in the middle of a file after doing some pattern matching
I Have a file by the name relog.001
I want to search for a line Local=IN
If found then skip
If not found then search for a line starting with 'Testion option Ok'
then insert the line 'Local=IN' after that.
File relog.001 contents before inserting
gpg RC (54321)
Testion Option OK
AIX.SHA1.So
File relog.001 contents after inserting
gpg RC... -
powerfulperl replied to Search for a particular line from a file and paste it in all the other filesin PerlCheck if this is ok
...Code:1. use strict; 2. use warnings; 3. my @filenames =(log.100, log.200, log.300); 4. foreach my $filename (@filenames) { 5. next if /\Afile\.100\Z/xms 6. eval { 7. open my $filehandle, '<', $filename; 8. open my $temphandle, '>', 'templog'; 9. foreach (<$filehandle>){Leave a comment:
-
powerfulperl replied to Search for a particular line from a file and paste it in all the other filesin PerlI can understand the above code but I want to write it in a different way so that it looks simple.Leave a comment:
-
powerfulperl replied to Search for a particular line from a file and paste it in all the other filesin PerlI have this code with me, but I am looking at easy and sophisticated code. Well I want the code to be very understandable and easy.
...Code:use strict; use warnings; my @filenames => (dw log.100 log.200 log.300); foreach my $filename (@filenames) { next if /\Afile\.100\Z/xms eval { open my $filehandle, '<', $filename or die Cannot open $filename; open my $temphandle,Leave a comment:
-
powerfulperl started a topic Search for a particular line from a file and paste it in all the other filesin PerlSearch for a particular line from a file and paste it in all the other files
I have several files Log.100 Log.200,Log.300 .... which are in an array
Log.100 file contains the data
gpg RC (54321)
Testion option OK
Local=IN
AIX.SHA1.So
and Log.200 file and other files contains data
gpg RC (54321)
Testion option OK
Linux.SHA1.so
All files misses the line 'Local=IN' except Log.100. So I want to copy the line Local=IN and then paste it in all the remaining... -
What u said is exactly true, but the problem here is i do not have any list of users whose accounts have been deleted. The first thing what i need to do is find the files whose owner account have been deleted and report the warning message for those files saying .. ORPHAN FILES FOUND IN THE FILE SYSTEM.Leave a comment:
-
Dude i want to write a perl script.. I thought of using the stat function but dont have any clue about how to go about it.. any help will be appreciated... thanks..Leave a comment:
-
Finding orphan files in linux system after owner account is deleted
I want to write a perl script for the below condition
Files not contained in the user's home directory and files contained in the user's home directory, and owned by that user(user's account deleted), will remain on the system. The file will still be owned by the deleted account's user ID (UID).
I want to throw a warning message whenever files(orphaned files) with no owners (i.e owner's deleted) are exists in the sy... -
sure dude will reply with the tried code.. thanks for the reply...Leave a comment:
-
Help needed to format the output of df command
Hi, I want to properly format the output of the df command and store the output in the array, the problem here is, in the third line if u guyz c when the location file system path extends the size, %, mounted on.. goes to next line when i try to push the values in the array line by line i want this to appear in one line.. any help is much appreciated.
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3...
No activity results to display
Show More
Leave a comment: