I have 13 text files and almost all of them contain the same string.
but some file has diffrent string inside.
I want to send that file which has a diffrent string inside
I have 13 text files and almost all of them contain the same string.
but some file has diffrent string inside.
I want to send that file which has a diffrent string inside
Hello Sagar,
Request you to please do always provide 3 important things required by the forums.
1st- Sample of Input_file(which has your sample input(s) etc) in CODE TAGS.
2nd- Sample of your expected output(which should come after running script/code) in CODE TAGS too.
3rd- Most important thing, your efforts. We encourage all users to add their efforts which they have put in order to solve their own problems in their posts in CODE TAGS, don't bother either your written code(s) are correct or wrong just post them in your posts and when you get guidance from this community then you could see where you were lacking or missing the things etc and that's the thought behind it(LEARNING).
Kindly do mention all details mentioned above clearly in your post and do let us know I am pretty sure you will get good guidance on this site, Keep learning, keep sharing on this site, cheers
Hello Sagar Singh,
I am having difficulty understanding what you are trying to do.
In post #1 you said you have thirteen files to search. In post #3 you said you have seven files and sort of showed us their contents. It seems that you are saying that each of your input files has a filename that is the string file followed by two octal or decimal digits, each file contains exactly one line of text, and if that line of text is not " Hello Sagar you want to print the filename and the contents of each file that does not contain that text and only that text with each output filename and contents separated from other filenames and their contents by an empty line of text.
But since none of your sample input files contain the leading <space> character that you say must be present, it would seem that the output should include every input file that you have shown us.
Have I understood your requirements correctly?
If you are not looking for a leading <space> character before "Hello Sagar" and just want a list of lines in file that do not contain the fixed string "Hello Sagar", then the command:
would give you a list of files that contain lines that do not match your pattern with the filename prepended to each line that does not match.
If you just want the filenames of files that do not contain your pattern, the code Ravinder suggested my be exactly what you want, but the grep -L option is an extension to the standards and will not be available on all systems. And, since you haven't told us what operating system you're using, we can't know if his suggestion will work in your environment.
If you really want the output to contain empty lines between the filenames and contents of each file that does not contain any line that matches your pattern, we could help you write a shell script that would do that, but we would need to know what shell you are using as well as what operating system you're using.
In your first post in this thread you said: "I want to send that file which has a diffrent string inside". Where do you want to send those files?
Please help us help you by providing details about the operating system you' are using, the shell you are using, more details about the format of the files you are processing, and an English description of the output you are trying to produce.
This User Gave Thanks to Don Cragun For This Post:
If you just want the filenames of files that do not contain your pattern, the code Ravinder suggested my be exactly what you want, but the grep -L option is an extension to the standards and will not be available on all systems.
All grep implementations i have seen so far have ":" (colon) as the separator between the matched contents and the filename (to be honest i don't know if this is required by the standards or just convention), so:
should provide a standards-conformant alternative to grep -L, no??
Hello Forum.
I have a file called abc.sed with the following commands;
s/1/one/g
s/2/two/g
...
I also have a second file called abc.dat and would like to substitute all occurrences of "1 with one", "2 with two", etc and create a new file called abc_new.dat
sed -f abc.sed abc.dat >... (10 Replies)
Hello
I would like to get know how to do this:
I got a big file (about 1GB) and I need to find a string (for instance by grep )
and then find all records in this file based on a string.
Thanks for advice.
Martin (12 Replies)
Hi All,
I'm trying to insert a string into a file at a specific location.
I'd like to add a string after the parent::__construct(); in my file.
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Controller extends CI_Controller {
function... (6 Replies)
Dear all,
I need your help, I have file like this:
file1:23456
01910964830098775635
34567
01942809546554654323
67589
26546854368698023653
09778
58716868568576876878
08675
86178546154065406546
08573
54165843543054354305
.
.file2:
23456 25
34567 26
67589 27 (2 Replies)
Hi all,
I have a question..
Here is my requirement..I have 500 files in a path say /a/b/c
I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Hi Everyone,
I am new to this forum and new to sed/awk programming too !!
I need to find particular string in file1(text file) and replace it with a value from another text file(file2) the file2 has only one line and the value to be replaced with is in the second column.
file 1:
(assert (=... (21 Replies)
How do I search for files that dont contain a certain string? I am currently trying
find ./logs -size +1c -exec grep -l 'Process Complete' {} \; -exec ls -l {} \; >
$TOD
Which gives me files that are reater han 0 file size and contain the string 'Process complete' but I want files that DONT... (13 Replies)
I have a string which contains following information:
<SZ.T><P ALIGN="CENTER"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="+3">Bundesregierung nimmt sich dicke Deutsche vor</FONT></P></SZ.T>
<SZ.UT><P ALIGN="CENTER"><FONT SIZE="+1"><I> Seehofer und Schmidt planen Kampagne gegen... (3 Replies)