LinuxQuestions.org
Register a domain and help support LQ
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 12-03-2009, 10:09 AM   #1
cbtsig215
LQ Newbie
 
Registered: Dec 2009
Posts: 1

Rep: Reputation: 0
simple bash script errors


Hi guys. I'm looking for a bit of help with a simple bash script I'm trying to create. From what I know about bash scripting (which is not much) it should work but doesn't. I'm using the latest release of ubuntu, but bash is bash... the distro shouldn't matter... i thought. Here's what I've got in the script.
_________________________________________________
echo Which file would you like to use?
read file
echo

echo What is the plugin ID you would like to process?
read ID
echo

echo Please wait.

cat $file | grep "|$ID|" | cut -d "|" -f3 | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 | uniq > $ID.tmp
cat $ID.tmp | tr "\n" "," > $ID.txt

echo Cleaning temp files.

rm $ID.tmp

echo $ID Finished.
__________________________________________________

It seems to have issues with the "read file" line and tells me that it's not a valid identifier. After that it says that echo is a command not found.

Hopefully I've included enough info for someone to give suggestions.

Thanks in advance.
 
Old 12-03-2009, 10:25 AM   #2
mk27
Member
 
Registered: Sep 2008
Distribution: fedora, gentoo, ubuntu
Posts: 148

Rep: Reputation: 23
Quote:
Originally Posted by cbtsig215 View Post
I'm using the latest release of ubuntu, but bash is bash... the distro shouldn't matter...
No, in fact it could not matter. As you say, bash is bash.

This script actually worked for me, altho I replaced the two cat lines with:

Code:
cat $file | grep "$ID"
Are you sure you are using exactly what you posted?
 
Old 12-03-2009, 05:25 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,301

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
It'd be easier if you post the exact error msgs ie run the prog and paste the invoking and all the msgs that appear.
Also, as above, post the exact code you are using.
 
Old 12-04-2009, 01:32 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
What happens if you add this as the first line of your script
Code:
#!/bin/bash
 
Old 12-04-2009, 03:33 AM   #5
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 329

Rep: Reputation: 140Reputation: 140
Does the script contain some non-printing characters?
For example, if the script has been edited in a Microsoft editor it could have some carriage return characters in it.

This will display control characters in the script using the '^' notation
(carriage returns will be shown as ^M )
Code:
cat --show-nonprinting script

Last edited by Kenhelm; 12-04-2009 at 03:34 AM.
 
  


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
Simple bash script please help! Cheloo Linux - General 3 07-13-2008 03:54 PM
Simple Bash Script Filipe Linux - Newbie 2 07-17-2007 09:07 AM
Simple Bash Script sachinh Linux - General 5 05-23-2007 09:54 PM
need help regarding my very simple bash script hottdogg Programming 3 05-02-2007 02:09 AM
Simple bash script Soulful93 Programming 1 06-04-2005 07:26 PM


All times are GMT -5. The time now is 09:04 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