Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-03-2009, 10:09 AM   #1
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 What is the plugin ID you would like to process?
read ID

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
Registered: Sep 2008
Distribution: fedora, gentoo, ubuntu
Posts: 148

Rep: Reputation: 23
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:

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

Rep: Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310Reputation: 2310
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
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1193Reputation: 1193Reputation: 1193Reputation: 1193Reputation: 1193Reputation: 1193Reputation: 1193Reputation: 1193Reputation: 1193
What happens if you add this as the first line of your script
Old 12-04-2009, 03:33 AM   #5
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 333

Rep: Reputation: 141Reputation: 141
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 )
cat --show-nonprinting script

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


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 08:21 AM.

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