0

I have am redirecting the file inside file but at the last the file is going to nullify, my code is like below

#!/bin/ksh
newlycreated=`cat /axphome/gdevarad/file.txt|awk '{print $1}'`

for i in $newlycreated
do

    cat file1.txt |grep -v $i > /axphome/gdevarad/file1.txt

done

file.txt contains

india    30
pakistan 40

file1.txt contains

india    30
pakistan 40
germany  50
japan    60
aus      70
1
  • 4
    You are not providing feedback on any of the answers to the question you are posting, the last one being stackoverflow.com/questions/41059906/…, unless you appreciate what people are doing to help you, you won't get much response here! Commented Dec 15, 2016 at 17:10

1 Answer 1

1

Replace > /axphome/gdevarad/file1.txt with >> /axphome/gdevarad/file1.txt so you do not overwrite your results in every loop.
Evn better: Place > /axphome/gdevarad/file1.txt after done .

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.