Redirect output directly with DOS end of line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Redirect output directly with DOS end of line
# 1  
Old 10-27-2011
Redirect output directly with DOS end of line

Hi guys,

I have some echo scripts and awk scripts like these:
Code:
echo "some text" > output1
.
.
awk '{....}{print}' input > output2

Both output1 and output2 are saved with unix END Of Line, then,
is there an option to include within echo command and awk command to save the output as DOS END Of Line?

Or the solution should be pipe a conversion before redirect to a file as example below?
Code:
echo "some text" | sed 's/$/\r/'  > output1
.
.
awk '{....}{print}' input | sed 's/$/\r/'> output2

Many thanks for any help.

Last edited by Ophiuchus; 10-27-2011 at 11:38 PM..
# 2  
Old 10-27-2011
You can use unix2dos utility for this...
Code:
root@bt:/tmp# od -c inputfile 
0000000   M   y       n   a   m   e       i   s       u   n   i   x  \n
0000020   W   h   a   t       i   s       y   o   u   r   s   ?  \n
0000037

root@bt:/tmp# unix2dos inputfile 
unix2dos: converting file inputfile to DOS format ...

root@bt:/tmp# od -c inputfile 
0000000   M   y       n   a   m   e       i   s       u   n   i   x  \r
0000020  \n   W   h   a   t       i   s       y   o   u   r   s   ?  \r
0000040  \n
0000041

--ahamed
# 3  
Old 10-28-2011
Yes ahamed! many thanks again, that works nice, I didn't know.

Best regards.
# 4  
Old 10-28-2011
dos2unix and unix2dos is the pair of the convert commands.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How To Redirect The Output When We Are Usinf EOF In The Same Line?

need to login 4 systems to check whether the systems are accessible or not using rlogin command,after each login i will exit.After issuing the command rlogin abc if it is not responding i will get a message of "connection timed out" . So i want to automate this task .so i tried like below: EX: ... (3 Replies)
Discussion started by: kankuro9x
3 Replies

2. Shell Programming and Scripting

How to redirect the output when we are usinf EOF in the same line?

need to login 4 systems to check whether the systems are accessible or not using rlogin command,after each login i will exit.After issuing the command rlogin abc if it is not responding i will get a message of "connection timed out" . So i want to automate this task .so i tried like below : EX:... (1 Reply)
Discussion started by: charanarjun
1 Replies

3. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

4. Shell Programming and Scripting

Redirect output of command line to for loop

I would like to redirect output of command line in for loop as $line. Output should be processed as line but instead it throw whole output. Could somebody help me on how to redirect output of command line and process it line by line without sending output to any file. below is my code ... (1 Reply)
Discussion started by: tapia
1 Replies

5. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

6. Shell Programming and Scripting

gawk (dos) insert backslash at end of line

I have created with the DOS-command dir a list of a directory. Directory of C:\Users\User\Documents 09.06.2011 20:50 48.322 file1.txt 02.11.2010 23:00 9.216 file2.txt 15.12.2010 21:06 26.793 file2.txt Now i would like to add the directory ahead of the filename. Therefore a... (6 Replies)
Discussion started by: sdf
6 Replies

7. UNIX and Linux Applications

Running oracle commands Directly from Command Line

In mysql, I can get what I want from a database without having to log into mysql. works great for me and it is perfect. now, i want to be able to do the same in oracle but I dont know how to. For example, if i want to retrieve information from the mysql database from the command line, i issue... (4 Replies)
Discussion started by: SkySmart
4 Replies

8. Shell Programming and Scripting

Add new parameters into a line, and redirect the line to other file

How can i add new parameters into a line, and redirect the line to other file? For example: 1.sh name:owner google:richard youtube:student I want a, for example 2.sh with: name:owner:description google:richard:search site youtube:student:video site In the 2.sh, I added a new column:... (7 Replies)
Discussion started by: rafazz
7 Replies

9. Windows & DOS: Issues & Discussions

how to return cygwin output to DOS

Hi, I have installed cygwin on my windows XP system. And I am trying to use the following code snippet: set SERVER="grep JDBCConnectionPool config.xml | gawk -F; '{print $2}'" sed -i 's/%SERVER%/WLMDEVDB1/' config.xml But it doesn't work because at runtime %SERVER% gets replaced by "grep... (2 Replies)
Discussion started by: illcar
2 Replies

10. Windows & DOS: Issues & Discussions

Output Of FIND command in dos to Excel File.

Hi I want to export DOS output of find command in Excel. However I want information to be in different column and not in same. I am using this command set /p String_to_search='Enter String to search !' set /p File_to_search='Enter File to search !' findstr /N "%String_to_search%"... (0 Replies)
Discussion started by: dashing201
0 Replies
Login or Register to Ask a Question