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. |
Quote:
This script actually worked for me, altho I replaced the two cat lines with: Code:
cat $file | grep "$ID" |
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. |
What happens if you add this as the first line of your script
Code:
#!/bin/bash |
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 |
All times are GMT -5. The time now is 10:48 PM. |