how to duplicate an output in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to duplicate an output in shell script
# 1  
Old 02-28-2012
Java how to duplicate an output in shell script

how to duplicate an output from a shell command?

for example:
`date` will give the current date to the console.
I want this to be displayed in console and also parallely store it in file or variable.

user1@solaris4:~> date
Tue Feb 28 17:48:31 EST 2012

user1@solaris4:~> date > file

Instead of two commands i want one command / syntax that does it...
I guess it will be possible using pipe.. but i wonder how...
# 2  
Old 02-28-2012
Code:
date | tee file

See "man tee" and also take note of the "-a" option.
This User Gave Thanks to methyl For This Post:
# 3  
Old 02-28-2012
tee

Hi,

Try this one,

Code:
date | tee -a file

tee cmd will redirect the output to file and as well as STDOUT.

Cheers,
RangaSmilie
This User Gave Thanks to rangarasan For This Post:
# 4  
Old 02-28-2012
Java thanks

thanks.. this what i was expecting..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies

2. Shell Programming and Scripting

A shell script to run a script which don't get terminated and send a pattern from the output by mail

Hi Guys, I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies

3. Shell Programming and Scripting

Shell Script function to use script name for log file output

Hi Team - I"m very new to Shell Scripting so I have a rather novice question. My forte is Windows Batch Scripting so I was just wondering what the Shell Script equivalent is to the DOS command %~n? %~n is a DOS variable that dispayed the script name. For instance (in DOS): REM... (11 Replies)
Discussion started by: SIMMS7400
11 Replies

4. Shell Programming and Scripting

Shell script to get duplicate string

Hi All, I have a requirement where I have to get the duplicate string count and uniq error message. Below is my file: Rejected - Error on table TableA, column ColA. Error String 1. Rejected - Error on table TableA, column ColB. Error String 2. Rejected - Error on table TableA, column... (6 Replies)
Discussion started by: Deekhari
6 Replies

5. Shell Programming and Scripting

Shell script to compare two files for duplicate..??

Hi , I had a requirement to compare two files whether the two files are same or different .... like(files contaisn of two columns each) file1.txt 121343432213 1234 64564564646 2345 343423424234 2456 file2.txt 121343432213 1234 64564564646 2345 31231313123 3455 how to... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

6. Shell Programming and Scripting

Shell Script output

Hi All, Below is the shell script for which desired output is required: Shell script: #!/bin/bash . /oracle/TEST/db/tech_st/11.1.0/TEST_<hostname>.env sqlplus /nolog << EOF connect / as sysdba spool /home/oracle/db_output.log @lockwait.sql prompt Database Locks ... (1 Reply)
Discussion started by: a1_win
1 Replies

7. Shell Programming and Scripting

Shell Script to Create non-duplicate lists from two lists

File_A contains Strings: a b c d File_B contains Strings: a c z Need to have script written in either sh or ksh. Derive resultant files (File_New_A and File_New_B) from lists File_A and File_B where string elements in File_New_A and File_New_B are listed below. Resultant... (7 Replies)
Discussion started by: mlv_99
7 Replies

8. Shell Programming and Scripting

shell script no output

xxxxxx (4 Replies)
Discussion started by: vinayrao
4 Replies

9. Shell Programming and Scripting

[How To?] Run shell script and get output into another shell.

Hi guys, I have a simple question, I want to store the output of the following command: As you can see it is running all the time, and we get a new line every 3sec. I just want to store these new lines into a single variable, so I can use it into a script. To clear the screen, and... (4 Replies)
Discussion started by: Thireus
4 Replies

10. Shell Programming and Scripting

Duplicate output without tee

Hi, Is there anyway to duplicate output without using tee? Let me explain the problem. We are use ssh to login to remote server and save output to a file using tee commands for auditing purposes. When we use vi editor in ssh session, letters get garbled and cant really use vi. Without tee it... (7 Replies)
Discussion started by: eagles1
7 Replies
Login or Register to Ask a Question