0

I have a .txt file which contains different words ( 1 million words ). I want to make a single output file containing information about the occurrences of words. I am using the command:

$ ./dumpindex /home/pankaj/indri-5.0/Query/indri_test_may.idx/ t "input_word_from_file" > /home/pankaj/output_file.txt

input_word_from_file is the query word from the file.

Issues:

  1. How to pass the input word automatically to the command from the file
  2. How to write the output file in append mode. ( because it gets updated with the latest output of the run command).
Inian
  • 80,270
  • 14
  • 142
  • 161
pankaj kashyap
  • 372
  • 2
  • 4
  • 13
  • 1
    append is >> instead of > – Drako May 31 '18 at 10:12
  • Thanks Drako. Any suggestions for issue (1). – pankaj kashyap May 31 '18 at 10:13
  • I agree that this should be deleted as duplicate - was just quicker to answer then search for obviously existing duplicate :D or change to have 1 question only – Drako May 31 '18 at 10:15
  • you have to read(google read file bash and find some tutorial on bash basics - my suggestion) that word from file and then use << to pass as input for command – Drako May 31 '18 at 10:16
  • @Drako can you please specify the command syntax. Thanks – pankaj kashyap May 31 '18 at 10:20
  • 1
    this line by line - split in words if necessary 9- also just do for your own good - google bash tutorial and go quickly through basics - it will make your life easier :) ) https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable – Drako May 31 '18 at 10:23

1 Answers1

1

for append use >> instead of >

$ ./dumpindex /home/pankaj/indri-5.0/Query/indri_test_may.idx/ t "input_word_from_file" >> /home/pankaj/output_file.txt
Drako
  • 773
  • 10
  • 22