Reputation: 43
when i'm writing that script and tyring to run it it says : unexpected end of file about [[line == temp ]] . i'm trying to read lines from file and delete all repetitions in the file. cleanFiles delete all the empty lines
while read line; do
while read temp; do
if[[ line == temp ]]; then
temp=" ";
fi
done
./cleanLines $1
done
Upvotes: 0
Views: 49
Reputation: 43
Hey guys another question that I got - I am new in bash and I need to merge few files , remove repetitions and sort them alphabetically. I am not allowed to use temporary files. CleanLines script doing echo . I can redirect it to the script that merge and again redirect merge to remove Repetitions and that at the end redirect again to sort script. Is it the easiest way to do that ?
Upvotes: 0
Reputation: 263197
You need to add a space after the if
.
if[[ line == temp ]]; then # wrong
if [[ line == temp ]]; then # still wrong, but see below
But that still compares the literal strings line
and temp
. If you want to refer to the values of the variables, you need $
signs:
if [[ "$line" == "$temp" ]]; then # right
The double quotes on "$temp"
prevent it from being interpreted as a glob pattern; I also added double quotes on "$line"
just for symmetry.
Upvotes: 3