Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8934527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:48:28+00:00 2026-06-15T09:48:28+00:00

When I run the following command in csh , I got nothing, but it

  • 0

When I run the following command in csh, I got nothing, but it works in bash.
Is there any equivalent in csh which can redirect the standard error to standard out?

somecommand 2>&1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:48:29+00:00Added an answer on June 15, 2026 at 9:48 am

    The csh shell has never been known for its extensive ability to manipulate file handles in the redirection process.

    You can redirect both standard output and error to a file with:

    xxx >& filename
    

    but that’s not quite what you were after, redirecting standard error to the current standard output.


    However, if your underlying operating system exposes the standard output of a process in the file system (as Linux does with /dev/stdout), you can use that method as follows:

    xxx >& /dev/stdout
    

    This will force both standard output and standard error to go to the same place as the current standard output, effectively what you have with the bash redirection, 2>&1.

    Just keep in mind this isn’t a csh feature. If you run on an operating system that doesn’t expose standard output as a file, you can’t use this method.


    However, there is another method. You can combine the two streams into one if you send it to a pipeline with |&, then all you need to do is find a pipeline component that writes its standard input to its standard output. In case you’re unaware of such a thing, that’s exactly what cat does if you don’t give it any arguments. Hence, you can achieve your ends in this specific case with:

    xxx |& cat
    

    Of course, there’s also nothing stopping you from running bash (assuming it’s on the system somewhere) within a csh script to give you the added capabilities. Then you can use the rich redirections of that shell for the more complex cases where csh may struggle.

    Let’s explore this in more detail. First, create an executable echo_err that will write a string to stderr:

    #include <stdio.h>
    int main (int argc, char *argv[]) {
        fprintf (stderr, "stderr (%s)\n", (argc > 1) ? argv[1] : "?");
        return 0;
    }
    

    Then a control script test.csh which will show it in action:

    #!/usr/bin/csh
    
    ps -ef ; echo ; echo $$ ; echo
    
    echo 'stdout (csh)'
    ./echo_err csh
    
    bash -c "( echo 'stdout (bash)' ; ./echo_err bash ) 2>&1"
    

    The echo of the PID and ps are simply so you can ensure it’s csh running this script. When you run this script with:

    ./test.csh >test.out 2>test.err
    

    (the initial redirection is set up by bash before csh starts running the script), and examine the out/err files, you see:

    test.out:
        UID     PID    PPID  TTY        STIME     COMMAND
        pax    5708    5364  cons0      11:31:14  /usr/bin/ps
        pax    5364    7364  cons0      11:31:13  /usr/bin/tcsh
        pax    7364       1  cons0      10:44:30  /usr/bin/bash
    
        5364
    
        stdout (csh)
        stdout (bash)
        stderr (bash)
    
    test.err:
        stderr (csh)
    

    You can see there that the test.csh process is running in the C shell, and that calling bash from within there gives you the full bash power of redirection.

    The 2>&1 in the bash command quite easily lets you redirect standard error to the current standard output (as desired) without prior knowledge of where standard output is currently going.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to run the following command and it says there is nothing to
I run the following command in Emacs unsuccessfully C-u How can you clear the
How can I run the following command using subprocess.Popen ? mysqldump database_name table_name |
I want to create a shell script which when called run the following command
Im trying to run the following command but its producing errors. hg backout -r
When I run the following command from command line, I can run 7-zip as
I'm trying to run the following command in Windows Server 2003 but sed creates
What happens if I run following command : mvn clean install sonar:sonar -Dmaven.test.skip=true I
I run the following command to link the different files in my project. /opt/gcc-4.7-cilkplus/bin/gcc
If I run the following command: >python manage.py test Django looks at tests.py in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.