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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-03-2009, 10:09 AM
|
#1
|
LQ Newbie
Registered: Dec 2009
Posts: 1
Rep:
|
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.
|
|
|
12-03-2009, 10:25 AM
|
#2
|
Member
Registered: Sep 2008
Distribution: fedora, gentoo, ubuntu
Posts: 148
Rep:
|
Quote:
Originally Posted by cbtsig215
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?
|
|
|
12-03-2009, 05:25 PM
|
#3
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,441
|
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.
|
|
|
12-04-2009, 01:32 AM
|
#4
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
What happens if you add this as the first line of your script
|
|
|
12-04-2009, 03:33 AM
|
#5
|
Member
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 360
Rep: 
|
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.
|
|
|
All times are GMT -5. The time now is 01:18 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|