LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-11-2006, 12:58 PM   #1
crewblunts
Member
 
Registered: Jan 2004
Location: Connecticut, USA
Distribution: Slackware & Ubuntu
Posts: 53

Rep: Reputation: 15
problem with if statement in bash script


I am getting an error, unexpected token near `fi' with this script.
all the files in question exist.
Code:
#!/bin/bash

exec < files.txt
while read i
do
        if [ mp3info "$i" ]
                cat "$i" >> badFiles.txt
        fi
done
thanks in advance,

Phil V
 
Old 03-11-2006, 01:14 PM   #2
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
Quote:
Originally Posted by crewblunts
I am getting an error, unexpected token near `fi' with this script.
all the files in question exist.
Code:
#!/bin/bash

exec < files.txt
while read i
do
        if [ mp3info "$i" ]
                cat "$i" >> badFiles.txt
        fi
done
thanks in advance,

Phil V
Try this:

Code:
#!/bin/bash

exec < files.txt
while read i
do
        if [ mp3info "$i" ]; then
                cat "$i" >> badFiles.txt
        fi
done
 
Old 03-11-2006, 01:24 PM   #3
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,724

Rep: Reputation: 434Reputation: 434Reputation: 434Reputation: 434Reputation: 434
or better:
Code:
...
  if mp3info "$i"
  then
...
 
Old 03-11-2006, 01:38 PM   #4
crewblunts
Member
 
Registered: Jan 2004
Location: Connecticut, USA
Distribution: Slackware & Ubuntu
Posts: 53

Original Poster
Rep: Reputation: 15
Thank you both. I don't know how i missed 'then'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash: Print usage statement & exit; otherwise continue using Bash shorthand operators stefanlasiewski Programming 9 02-07-2006 06:20 PM
bash statement os2 Programming 2 03-20-2005 11:13 PM
how to close 'else' statement block in bash script servnov Linux - General 9 11-12-2004 04:53 PM
Bash script problems with "if" statement adz Programming 2 05-22-2004 04:34 AM
Need help adding an IF / ELSE statement to my Bash Script Relix Linux - General 1 08-01-2002 03:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration