Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I echo commands in a tcsh script?

Yes. I know I shouldn't be using it for scripting. Yes. It is rubbish. I am indeed a fool.

Nevertheless.

I'd like to see the commands the script is executing, for debugging purposes. I think you get this effect with set -x or set -v in bash scripts.

So e.g., if the script were

#!/bin/tcsh

echo "Hello"

then when it ran, I'd see

echo "Hello"
Hello
like image 875
John Lawrence Aspden Avatar asked Feb 01 '12 11:02

John Lawrence Aspden


People also ask

How do you echo a command in shell script?

The echo command writes text to standard output (stdout). The syntax of using the echo command is pretty straightforward: echo [OPTIONS] STRING... Some common usages of the echo command are piping shell variable to other commands, writing text to stdout in a shell script, and redirecting text to a file.

What is echo in scripting?

Echo is a Unix/Linux command tool used for displaying lines of text or string which are passed as arguments on the command line. This is one of the basic command in linux and most commonly used in shell scripts.

What does the echo command do in command line?

In computing, echo is a command that outputs the strings that are passed to it as arguments. It is a command available in various operating system shells and typically used in shell scripts and batch files to output status text to the screen or a computer file, or as a source part of a pipeline.


2 Answers

Put:

set echo and/or set verbose

at the top of your script. That will print out everything that happens in your script and are equivalent to the bash set -x and set -v commands.

like image 125
Anonymous Avatar answered Oct 21 '22 11:10

Anonymous


Lets say your script name is tcsh_file Lets assume this file includes shebang as well.

now run this command on terminal

tcsh -x tcsh_file

this will print every line before executing it. it's basically an interactive mode of execution.

Is this what you needed?

like image 25
Ani Avatar answered Oct 21 '22 13:10

Ani