write statement into one file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting write statement into one file
# 1  
Old 06-25-2007
Bug write statement into one file

I have one file name start.sh in rinku directory. I want to move it to rinku1 directory. I also mantain log file. In the log file I want to write the the statement whenever the move is failed.
Example:
>echo `mv /rinku/me.tx ../rinku1` | tee -a log1
mv: me.tx: cannot access: No such file or directory


I want to write mv: me.tx: cannot access: No such file or directory into log1.

It is not working. I am working in ksh.

Please help.
Thanx in advance.......Smilie
# 2  
Old 06-25-2007
Code:
mv /rinku/me.tx ../rinku1 2>> log1

# 3  
Old 06-25-2007
Power IT's working but....

can't I use tee instead of >>. bcoz with this command mv: me.tx: cannot access: No such file or directory this line is not shown during runtime. I have to show it in runn time also.

please suggest.
# 4  
Old 06-25-2007
Where there is no such file a100

Code:
mv a100 a200 2>&1 | tee -a filename.log

Will display in stdout and file
# 5  
Old 06-25-2007
thanx

It is working. Cloud u please explain the meaning of 2>&1

Thanx .....
# 6  
Old 06-25-2007
Quote:
Originally Posted by rinku
It is working. Cloud u please explain the meaning of 2>&1

Thanx .....
Redirect output of stderr (2) to where stdout (1) is redirected
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

2. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

3. Shell Programming and Scripting

Awk/sed problem to write Db insertion statement

Hi There, I am trying to load data from a csv file into a DB during our DB migration phase. I am successfully able export all data into a .csv file but those have to rewritten in terms insert statement which will allow for further population of same data in different DB My exiting csv record... (6 Replies)
Discussion started by: bhaskar_m
6 Replies

4. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

5. Shell Programming and Scripting

Need a clue to write a IF statement

Hi all, i am writing a shell script in which i got stuck when tried to use a if statement. This is my code : #!/bin/sh today=`date +"%a %b %e"` find /prod/logs -name '*.log' -mtime 0 -exec cp {} /home/hzjnr0/test \; find /home/hzjnr0/test -type f -exec grep -i "successfully" {} \; >... (6 Replies)
Discussion started by: Soma Das
6 Replies

6. Shell Programming and Scripting

How to write If statement using && and operator in Unix

Hi What is the syntax for if statement using && and || operator? if && ] || here its giving me an error to this if statement any suggestion?? (2 Replies)
Discussion started by: Avi
2 Replies

7. Shell Programming and Scripting

Extract data from an XML file & write into a CSV file

Hi All, I am having an XML tag like: <detail sim_ser_no_1="898407109001000090" imsi_1="452070001000090"> <security>ADM1=????</security> <security>PIN1=????</security> <security>PIN2=????</security> ... (2 Replies)
Discussion started by: ss_ss
2 Replies

8. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

9. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

10. Shell Programming and Scripting

How to write an OR statement

Hi all, I want to check if the first or the second or the third argument of call to a shell script is empty. How do i do that in a short way. I watched some examples and i believe if checks if an argument is NULL. If so, how can i add the checks for argument 2 and 3 in the statement? ... (1 Reply)
Discussion started by: aukequist
1 Replies
Login or Register to Ask a Question