Compare 1 with another string in bash

0 votes

I've spent 2 hours with an if statement, that never works like I want:

#should return true
if [ "$1" == "355258054414904" ]; then 

Here is the whole script:

#!/bin/bash

param=$1
INPUT=simu_900_imei_user_pass.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT ime not found"; exit 99; }
while read imei email pass 
do
    echo "First Parameter-IMEI: $1"
    if [ "$1" == "355258054414904" ]; then
        echo "GOOD"
    fi
done < $INPUT
IFS=$OLDIFS

This is the output of the script:

First Parameter-IMEI: 355258054414904
First Parameter-IMEI: 355258054414904
First Parameter-IMEI: 355258054414904

I have seen a lot of pages about the subject, but I can't make it work :(

EDIT: I Join the content of csv for better understanding ! Tx for your help !

4790057be1803096,user1,pass1
355258054414904,juju,capp
4790057be1803096,user2,pass2
358854053154579,user3,pass3
Jun 9, 2022 in Linux Administration by Rahul
• 3,380 points
358 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Linux Administration

0 votes
1 answer

Compare $1 with another string in bash

The explanation $1 doesn't match is on ...READ MORE

answered Jun 13, 2022 in Linux Administration by Korak
• 5,820 points
626 views
0 votes
1 answer

Comparing two string variables in an 'if' statement in Bash

1. For string comparison, use: if [ "$s1" ...READ MORE

answered May 15, 2019 in Linux Administration by Shubham
• 13,490 points
1,769 views
0 votes
0 answers

How do I copy folder with files to another folder in Unix/Linux?

I am having some issues copying a ...READ MORE

Apr 13, 2022 in Linux Administration by Soham
• 9,710 points
390 views
0 votes
0 answers

How do I copy folder with files to another folder in Unix/Linux?

I am having some issues to copy ...READ MORE

Apr 21, 2022 in Linux Administration by Edureka
• 13,690 points
418 views
0 votes
1 answer

How to check if a string contains a substring in Bash?

You ought to recollect that shell prearranging ...READ MORE

answered May 27, 2022 in Linux Administration by Korak
• 5,820 points
1,234 views
0 votes
0 answers
0 votes
0 answers

How to split a string into an array in Bash?

In a Bash script, I would like ...READ MORE

Jun 9, 2022 in Linux Administration by Rahul
• 3,380 points
587 views
0 votes
1 answer

How to take input from user in bash script?

You can use if-else branch to check ...READ MORE

answered Jan 31, 2019 in Linux Administration by Omkar
• 69,220 points
1,154 views
0 votes
1 answer

generating a list of files with their absolute path in Linux

If you find an absolute path to start with, ...READ MORE

answered May 16, 2019 in Linux Administration by Upasana
• 8,620 points
1,399 views
0 votes
1 answer

How to extract file base name without path and extension in bash?

You don't actually have to call the ...READ MORE

answered May 31, 2019 in Linux Administration by Shubham
• 13,490 points
5,933 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP