how to avoid new line characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to avoid new line characters
# 1  
Old 06-02-2009
CPU & Memory how to avoid new line characters

Hi,
I am using gzip command to compress the files at the UNIX server and FTP ing it in Binary mode to Windows server.(If ASCII mode is used im getting the output as junk characters)
When i extract the files at Windows server a new line character is getting appended to the output file which is not needed.
the output file should have the text entered in new line instead of new line character.
Output file i get:
0008708 20090515386047FINALA [] 7176 1000002 [] 0008708 20090515386048PARTC []1863 1000002 []0008708 20090516386047FINALB

Actual output file needed
0008708 20090515386047FINALA
7176 1000002
0008708 20090515386048PARTC 1863 1000002
0008708 20090516386047FINALB

i am getting a box []character as an new line character instead it should be a new line itself.
Kindly help to avoid this issue.
# 2  
Old 06-02-2009
Anytime you transfer a file from UNIX to Windows as binary the end of record will only have a newline and not carriage return line feed which Windows Uses. So you have to either convert the files on the UNIX side before you ftp them over to windows. Or on the windows box. You are probably using notepad to look at the files on Windows. If you use wordpad or write it should display the files correctly. So you can use the tr command for example on the UNIX side to convert the files. If you have Windows Services for Unix on windows you can use a flip command to convert the files from UNIX to windows.
# 3  
Old 06-03-2009
Thanks a lot for your advice..
But if i transfer them in Ascii mode i am getting the files with lots of junk character can we avoid this issue?
# 4  
Old 06-04-2009
I am not saying transfer them in ASCII mode. You have compressed the files into binary files using gzip. Therefore you have to transfer the files in binary mode. All I am saying is that when you gunzip the files on the other system which you said was windows then the files that were zipped up need to be converted to windows files. So either you need to convert the files before you gzip them to Windows files or convert them to windows after you gunzip them on the windows side. The only way you can transfer them in ASCII mode is not to compress the files together using gzip.
# 5  
Old 06-04-2009
Format the files in the UNIX environtment before you compress them with the following code and transfer the compressed file in binair mode:

Code:
awk '{printf "%s\r\n", $0}' unixfile > dosfile

The command places a CR-LF pair at the end of the lines and does the same like a tool as unix2dos.

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove first 2 characters and last two characters of each line

here's what im trying to do. i have a file containing lines similar to this: data.txt: 1hsRmRsbHRiSFZNTTA1dlEyMWFkbU5wUW5CSlIyeDFTVU5SYjJOSFRuWmpia0ZuWXpKV2FHTnRU 1lKUnpWMldrZFZaMG95V25oYQpSelEyWTBka2QyRklhSHBrUjA1b1kwUkJkd3BOVXpWM1lVaG5k... (5 Replies)
Discussion started by: SkySmart
5 Replies

2. Shell Programming and Scripting

Avoid printing entire line if string not found

so im searching the process table with: ps -ef | awk -F"./rello.java" '{ print substr($0, index($0,$2)) }' I only want it to print everything that's infront of the "./rello.java". That's because im basically getting the arguments that was passed to the rello.java script. this works. ... (2 Replies)
Discussion started by: SkySmart
2 Replies

3. Shell Programming and Scripting

Ksh: Read line parse characters into variable and remove the line if the date is older than 50 days

I have a test file with the following format, It contains the username_date when the user was locked from the database. $ cat lockedusers.txt TEST1_21062016 TEST2_02122015 TEST3_01032016 TEST4_01042016 I'm writing a ksh script and faced with this difficult scenario for my... (11 Replies)
Discussion started by: humble_learner
11 Replies

4. Shell Programming and Scripting

Avoid single line output from function

I am new to shell scripting and wished to get few things clarified. While calling functions within shell script, output comes out as single line irrespective of the no of echos or newlines I tried within function + the echo -e used to invoke function ( as instructed online) : #!/bin/sh inc() {... (1 Reply)
Discussion started by: RMath
1 Replies

5. Shell Programming and Scripting

[Solved] How to separate one line to mutiple line based on certain number of characters?

hi Gurus, I need separate a file which is one huge line to multiple lines based on certain number of charactors. for example: abcdefghi high abaddffdd I want to separate the line to multiple lines for every 4 charactors. the result should be abcd efgh i hi gh a badd ffdd Thanks in... (5 Replies)
Discussion started by: ken6503
5 Replies

6. UNIX for Dummies Questions & Answers

How to specify beginning-of-line/end-of-line characters inside a regex range

How can I specify special meaning characters like ^ or $ inside a regex range. e.g Suppose I want to search for a string that either starts with '|' character or begins with start-of-line character. I tried the following but it does not work: sed 's/\(\)/<do something here>/g' file1 ... (3 Replies)
Discussion started by: jawsnnn
3 Replies

7. Shell Programming and Scripting

How to avoid new line

Hi, I am having multiple echo statements to print output echo "$VAr" echo "$lenght" echo "$sum" I get the output as 12 24 36 I need the output to be 12 24 36. How do i arrive at this. Thanks in advance (4 Replies)
Discussion started by: krashraj
4 Replies

8. Shell Programming and Scripting

How to avoid the truncating of multiple spaces into a single space while reading a line from a file?

consider the small piece of code while read line do echo $line done < example content of example file sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the output is like sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the... (4 Replies)
Discussion started by: Kesavan
4 Replies

9. Shell Programming and Scripting

Plz Help-how to avoid blank next line

Hi, I want to pick the latest file name and save it in a file. later i'll be insert this file name in a oracle table.But i m getting a strange issue. while putting the file name to a file, some extra blank line also coming to that file.i m using cmd.... ls -t *_xxx_*.dat head - 1 > yyy.csv In... (5 Replies)
Discussion started by: palash
5 Replies

10. Shell Programming and Scripting

Need to avoid empty line error

Hi, Below shell script executes based on liasted data files parameters.But small problem need to avoid ,If any empty line occures in dat files it's throwing oracle error .Need to ignore empty lines (means does not ready by script).Please advice. #/bin/sh adsts=`cat... (2 Replies)
Discussion started by: krajasekhar.v
2 Replies
Login or Register to Ask a Question