LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-20-2008, 11:22 PM   #1
pclimmex
LQ Newbie
 
Registered: Jun 2008
Posts: 1

Rep: Reputation: 0
syntax error unexpected token near "then"


I am working with Knoppix 4
I am working to replace a file on a crashed computer. I can locate the file and a second file of the same name on the hd1 (atisgkaf.sys WinXP)

I can not just replace it with the "good" file because of permissions. I am using the Knoppix Hacks (O'Reilly)
It states that writing to NTFS files can be done.

I was going to test my abilities with a few different command line attempts before trying to replace the file.

I entered ... from the book... p231
$ find /mnt/hda1/ -name *.cab -exec sh -c "if cabextract -l \"{}\" 2>/dev/null | grep atisgkaf.sys; then echo \"*{}\"; fi; " \;

return is an syntax error unexpected token near "then". If I remove"then" it changes to a different
 
Old 06-20-2008, 11:51 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
Some tips:
  1. You need to place quotes around your *.cab so that the shell doesn't try to glob it before find gets a chance to see the *.
  2. With a simple if a then b, you can use a simpler construct: a && b.
  3. Using single quotes around your command passed to sh is easier, and find still looks for {} inside (since the shell has already removed the quotes, find sees {} just fine).

So, ultimately you have:

Code:
find /mnt/hda1 -name '*.cab' -exec sh -c 'cabextract -l "{}" 2>/dev/null | grep atisgkaf.sys && echo "*{}"' \;

Last edited by Mr. C.; 06-20-2008 at 11:57 PM.
 
  


Reply

Tags
error, syntax, token


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
chmod: 1: Syntax error: "(" unexpected - what's this mean and how do I fix it? SeriesOne Linux - Newbie 6 02-22-2008 02:18 PM
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 10:28 AM
syntax error near unexpected token deskjockey39 Linux - General 2 01-16-2007 09:47 AM
syntax error for unexpected token `(' Steve Spurr Linux - Newbie 6 09-22-2006 09:19 AM
syntax error near unexpected token ` mattyspatty Programming 8 05-07-2006 06:19 PM


All times are GMT -5. The time now is 02:07 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration