Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can bash -v output be redirected?

Tags:

bash

starting bash with -v option produces a long output to the console

$ bash -v

source ~/Dropbox/bin/tim_functions.sh

\#!/bin/bash
...several hundred more lines

I would like to capture the output to a file to make it easier to browse through, but I have tried bash -v 2>&1 > out_bash.txt and bash -v | tee out_bash.txt and cannot capture the information on the terminal screen within a file. It is as if the verbose output is neither stderr or stdout. How can this be?

Can anyone suggest a way to capture the output of bash -v ?

like image 949
Tim Avatar asked Jun 22 '12 05:06

Tim


People also ask

How do you redirect output?

When the notation >filename is added to the end of a command, the output of the command is written to the specified file name. The > symbol is known as the output redirection operator. The output of a process can be redirected to a file by typing the command followed by the output redirection operator and file name.

How do I redirect output to a file?

Redirect Output to a File Only To redirect the output of a command to a file, type the command, specify the > or the >> operator, and then provide the path to a file you want to the output redirected to. For example, the ls command lists the files and folders in the current directory.

How does bash redirection work?

Before a command is executed, its input and output may be redirected using a special notation interpreted by the shell. Redirection allows commands' file handles to be duplicated, opened, closed, made to refer to different files, and can change the files the command reads from and writes to.


1 Answers

 bash -v 2>&1 > out_bash.txt

is not what you want, it should be

 bash -v  >out_bash.txt 2>&1
like image 182
pizza Avatar answered Oct 04 '22 17:10

pizza