Sponsored Content
Top Forums Shell Programming and Scripting tcsh - understanding difference between "echo string" and "echo string > /dev/stdout" Post 302668597 by marcink on Monday 9th of July 2012 03:01:53 PM
Old 07-09-2012
Quote:
Originally Posted by shamrock
The first line "Redirected to STDOUT" which you expect to show up in the file mystdout got overwritten by the last one "Should default to STDOUT without redirection"...and this will happen with any sh not just the tcsh...and by appending to mystdout you will see both the lines there...
Code:
./out_to_streams.csh >> mystdout

Tried it and I get the same result. I've tried "append redirect" (i.e. ">>") on the command line as suggested, and it did not work. I changed it in the script as well:
Code:
#!/bin/tcsh -f

echo Redirected to STDOUT >> /dev/stdout
echo Redirected to STDERR >> /dev/stderr

echo Should default to STDOUT without redirection

And "Redirect to STDOUT" still gets lost. I've tried all four combinations (i.e. ">" vs ">>" in script and on command line), and in all cases "Redirect to STDOUT" gets lost.

Is there some bizarre handling of the IO streams and redirects in tcsh that can explain this behavior?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

input string="3MMTQSZ348GGMZRQWMJM4SD6M";output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6

input string="3MMTQSZ348GGMZRQWMJM4SD6M" output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6M" using linux shell script (4 Replies)
Discussion started by: pankajd
4 Replies

2. Shell Programming and Scripting

"sed" to check file size & echo " " to destination file

Hi, I've modified the syslogd source to include a thread that will keep track of a timer(or a timer thread). My intention is to check the file size of /var/log/messages in every one minute & if the size is more than 128KB, do a echo " " > /var/log/messages, so that the file size will be set... (7 Replies)
Discussion started by: jockey007
7 Replies

3. Shell Programming and Scripting

Difference between using "echo" builtin and /bin/echo

So in my shell i execute: { while true; do echo string; sleep 1; done } | read line This waits one second and returns. But { while true; do /bin/echo string; sleep 1; done } | read line continues to run, and doesn't stop until i kill it explicitly. I have tried this in bash as well as zsh,... (2 Replies)
Discussion started by: ulidtko
2 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

6. AIX

echo $varibla | mail -s "subject" "xxx@xxx.com" not ruuning as expected

Hi Folks, As per the subject, the following command is not working as expected. echo $variable | mail -s "subject" "xxx@xxx.com" Could anyone figure it out whats wrong with this. I am using AIX box. Regards, (2 Replies)
Discussion started by: gjarms
2 Replies

7. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

8. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

9. Shell Programming and Scripting

About reture with string and keep other "echo" info

I use below code to get ip, and I want to echo something in the function, but the $IP will be all the value from "echo" I just want to get the real ip, and keep the echo info, any help #!/bin/bash get_ip() { ip=$(grep -B2 "00:01:02:03:04:05" ip_tmp.log |head -1 |awk '{print $2}') ... (4 Replies)
Discussion started by: yanglei_fage
4 Replies

10. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies
SYSTEMD-CAT(1)							    systemd-cat 						    SYSTEMD-CAT(1)

NAME
systemd-cat - Connect a pipeline or program's output with the journal SYNOPSIS
systemd-cat [OPTIONS...] [COMMAND] [ARGUMENTS...] systemd-cat [OPTIONS...] DESCRIPTION
systemd-cat may be used to connect STDOUT and STDERR of a process with the journal, or as a filter tool in a shell pipeline to pass the output the previous pipeline element generates to the journal. If no parameter is passed, systemd-cat will write everything it reads from standard input (STDIN) to the journal. If parameters are passed, they are executed as command line with standard output (STDOUT) and standard error output (STDERR) connected to the journal, so that all it writes is stored in the journal. OPTIONS
The following options are understood: -h, --help Prints a short help text and exits. --version Prints a short version string and exits. -t, --identifier= Specify a short string that is used to identify the logging tool. If not specified, no identification string is written to the journal. -p, --priority= Specify the default priority level for the logged messages. Pass one of "emerg", "alert", "crit", "err", "warning", "notice", "info", "debug", or a value between 0 and 7 (corresponding to the same named levels). These priority values are the same as defined by syslog(3). Defaults to "info". Note that this simply controls the default, individual lines may be logged with different levels if they are prefixed accordingly. For details see --level-prefix= below. --level-prefix= Controls whether lines read are parsed for syslog priority level prefixes. If enabled (the default), a line prefixed with a priority prefix such as "<5>" is logged at priority 5 ("notice"), and similar for the other priority levels. Takes a boolean argument. EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise. EXAMPLES
Example 1. Invoke a program This calls /bin/ls with STDOUT/STDERR connected to the journal: # systemd-cat ls Example 2. Usage in a shell pipeline This builds a shell pipeline also invoking /bin/ls and writes the output it generates to the journal: # ls | systemd-cat Even though the two examples have very similar effects the first is preferable since only one process is running at a time, and both STDOUT and STDERR are captured while in the second example only STDOUT is captured. SEE ALSO
systemd(1), systemctl(1), logger(1) systemd 208 SYSTEMD-CAT(1)
All times are GMT -4. The time now is 08:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy