Script to fill in sed input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to fill in sed input
# 8  
Old 01-31-2012
Well yes! the file has over 1 million lines and its pretty big!

Code:
awk 'NR==FNR{A[$1]=1;next}!A[$1]' excludefile inputfile > outputfile

this command did something but it didn't work! it took only a second to run! and produced a huge file but it doesn't seem that it read the arguments from the exclude file properly.
as when I do grep for one of the numbers in the exclude file I still see it in the outputfile.

any other things I could tweak?

Thank you
# 9  
Old 01-31-2012
Define 'pretty big'. Megabytes? Gigabytes? Terabytes? When you start processing hundreds of megs of data and up, things can take a while. You may just need to be patient. If your exclude file is also enormous, beware -- the entire thing has to be loaded into memory for your file to be processed efficiently! How much RAM do you have?

The 'grep' version ought to be particularly efficient unless you're running out of memory and eating into swap.

Could you post a sample of your input file?

These text files weren't edited/created on Windows, were they? That will throw lots of things out of whack.

Whenever awk misbehaves, try 'nawk'. Many systems use the more modern nawk by default when you run awk, a few still don't.

Last edited by Corona688; 01-31-2012 at 02:58 PM..
# 10  
Old 01-31-2012
Could you post a sample of both the input file and the exclude file?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script to fill the entire row of Excel file with color based on pattern match

Hi All , I have to write one Perl script in which I need to read one pre-existing xls and based on pattern match for one word in some cells of the XLS , I need to fill the entire row with one color of that matched cell and write the content to another excel Please find the below stated... (2 Replies)
Discussion started by: kshitij
2 Replies

2. Shell Programming and Scripting

sed with standard input not working

I am trying use sed to replace a string in a file with input string passed, but it is not replacing the string. instead it replace as $1. Please find below the code. echo $1 sed -i.$now "s/http.*.myservice.*.war/$1/" tempfile.xml I am running above code as below myscript.sh ReplaceString... (4 Replies)
Discussion started by: sakthi.99it
4 Replies

3. Emergency UNIX and Linux Support

Script to fill the file system mount with empty files to desired size

We are regularly using for our testing, where we are manually filling up the mount with desired size with following command dd if=/dev/zero of=file_2GB bs=2048000 count=2000 We are planning to automate the task where taking input for % of size as one input and the name of the file system... (8 Replies)
Discussion started by: chandu123
8 Replies

4. Shell Programming and Scripting

sed execution with input from keyboard

> sed '' Hello hi Hello output How hi output ^D How > sed should take each line as input, process and output the result. In the above scenario the input is passed from keyboard and the output of 'Hello' as you can see is displayed on the screen after 'hi' is passed as input but not as... (1 Reply)
Discussion started by: loggedin.ksh
1 Replies

5. Shell Programming and Scripting

Script which fill data in XML file

Hello, I need help for writing a script that fills already generated xml file with data from oracle database and random sequences. For example if we have the following tags: <ns1:message> <ns1:messageId> </ns1:messageId> <ns1:languageCode> </ns1:languageCode>... (10 Replies)
Discussion started by: zb99
10 Replies

6. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

7. Shell Programming and Scripting

Sed with unescaped input

a shell script variable from user input, via read, will typically have special characters in it - i.e. sip:29384902834!someServer.com@someOtherServer.com this value has to stay formatted like this because it being used by curl in a post to php. but it is also being used by sed to replace the... (4 Replies)
Discussion started by: Gripp
4 Replies

8. Shell Programming and Scripting

Reading from input with sed

I am trying to edit a file in shell script using sed. I need to get the input from command line suppose script.sh sed"/s place=/place=california/g" > /root/user/mark.txt echo " place changed " the above code searches for string place in the file mark.txt and replaces with place=... (5 Replies)
Discussion started by: sriki32
5 Replies

9. Shell Programming and Scripting

SED command using multiple input files

What is the syntax to use multiple input files in a SED command. i.e. substitute a word with a phrase in every file in a directory. for every file in /usr/include that has the word "date" in the file grep -l '\<date\>' /usr/include/*.h find each occurrence of the word "time" in the file &... (3 Replies)
Discussion started by: sheoguey
3 Replies

10. Shell Programming and Scripting

script to fill up disk space for testing purpose

Hello everyone I am new to this forum I am working on a project and needed a test script to fill up a disk partition /tmp/data to see how the program fails. The system I am working on is a redhat 5.3. Is there anything out there? Thanks. (10 Replies)
Discussion started by: dp100022
10 Replies
Login or Register to Ask a Question