So, I'm writing a shell script to help automate a process I'm doing. Basically I want to take input from the user for 2 variables, then create a file that consists of:
then run an awk script. I'm pretty new to unix though, and so far I've been creating new files by hitting ctrl-d at the end of my input, like so:
My google-fu is failing me. Is there a way I can tell the script "this is where the file you're making ends" without hitting ctrl-d? Really stupid question I know, but hopefully there's a simple answer!
ctrl-d is not a "cat" thing by the way, it's a terminal thing. It forces the terminal to send an end-of-file condition. If you do ctrl-d just at your prompt, it will probably log you out.
What you want sounds like a here-document. You can tell the shell to build a document and feed it into cat.
Note that the ending EOF cannot be indented, it must be at the beginning of the line.
Yeah, I knew ctrl-d wasn't a cat thing. That's why I was pretty embarrassed by this post. But if you can't ask anonymous people on the internet, who can you ask? :P
There are some subtleties with regard to quoting, expansions, and leading tabs. I suggest you carefully read the relevant section of your shell's manual page.
Thanks everybody, that worked like a charm. So while we're here, how should I be telling cat to end files if I'm just doing command line work besides ctrl-d?
If you want to use the terminal to send an end-of-file signal, that's what ctrl-d is for. You might be able to redefine it to another key if you really wanted, but it's what it is for.
If you want a better way to edit files, try an editor like vi, vim, pico, or nano.
I am running the gaussian program on UNIX with bash and I want to form a script that will email me once the output life terminates either "normal termination" or "false" I just started learning this last week so could you let me know how to go about this.:b: (13 Replies)
I have a script in which we have used nohup. Once script is executed it will be terminated only when enter key is pressed. I want the script to be terminated without pressing enter key
nohup imqbrokerd -name user_id port 2>1 1>$home_`date` &
I am a newbie to shell, Kindly please help (3 Replies)
Hi
I have a Shell script that needs to execute a command at the
End of the excursion of other script And I cant get a handel
On the trap command. And that is if the trap command
Is the proper way to go
this is a extract of the script
MYHOST=`hostname| cut -d. -f1`
echo $MYHOST
... (4 Replies)
Hello,
So I sorted my file as I was supposed to:
sort -n -r -k 2 -k 1 file1 | uniq > file2
and when I wrote
> cat file2
in the command line, I got what I was expecting, but in the script itself
...
sort -n -r -k 2 -k 1 averages | uniq > temp
cat file2
It wrote a whole... (21 Replies)
I'm writing a script to archive data. First, the files are all rsync'd to the archive directory via NFS mounts(I know not the most efficient, but the only choice in this situation), then I use md5sum to validate the transfers. During execution of the script, it will exit for no apparent reason. It... (6 Replies)
Hello all,
Here is the problem:
A ksh script (let's call it abc.sh) gets kicked off from a menu program using "nohup abc.sh &". The process ID of abc.sh can be recieved (pid=$!).
abc.sh runs an Oracle PL/SQL script (it creates a child process).
In order to stop the abc.sh (and the child)... (5 Replies)
I'm having trouble with Abnormal Termination errors. What are they, what causes them and how can I prevent them from happening? Are they application specific? (2 Replies)