[bash] code wont work - here document
Hi guys,
reading advanced bash scripting, I found this example: Code:
#!/bin/bash Can you tell me why? actually if you paste this in to bash: Code:
echo "Listing of "$directory":"; echo Any info would be appreciated, since the code looks logically correct. |
Works for me (with columns misaligned because of different ls -l output).
Does it run at all? Try Code:
#!/bin/bash Code:
#!/bin/bash |
after running test.sh
I get Code:
[~] echo $? |
Quote:
|
When you added the "set -xv" to the script and reran it, did it still just produce the prompt and no output?
Mine produced: Code:
[tommy@athlonz ~]$ ./test.sh |
Not an answer to your question, but a common alternative to your example is to use the cat command rather than the sed command. With that change, your sample code would look like this:
PHP Code:
|
@tommylovell
Everything went exactly the same... no output from the script and a new line with a prompt. I was noticing that when i pasted the code all the expanded variables where missing ("$1" was showing up like "".). I do not know why, after I inserted all variables everything worked as you mentioned. @PTrenholme Thanks for the idea, I tried it and it works perfectly! |
All times are GMT -5. The time now is 09:45 PM. |