Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using this script to find information stored in one file using other file as a source for variables to look for:

#!/bin/bash
clear
file=/home/victor/Documentos/Temporal/13-06-04_Cuentas_para_revisar_cajas.txt
while IFS= read -r line
do
echo $line
cat Inventory.csv | grep "$line" >> cuentasxcajas.txt
done < $file
echo "done"

but the file cuentasxcajas.txt is empty, any suggestions?

share|improve this question
    
Possible duplicate: stackoverflow.com/questions/17291557/… –  Adobe Jul 7 '13 at 5:53

1 Answer 1

If I had your task to do, I would proceed thus:

grep -f '/home/victor/Documentos/Temporal/13-06-04_Cuentas_para_revisar_cajas.txt' -- Inventory.csv > cuentasxcajas.txt

No need for a Bash script, of for loops of for useless uses of cats. Just make sure you don't have empty lines in the file /home/victor/Documentos/Temporal/13-06-04_Cuentas_para_revisar_cajas.txt.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.