Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Linux file: Notepad displays all data in one line

Posted on 2010-08-30
10
696 Views
Last Modified: 2013-12-26
Hey,

grep "to=<no.reply+" /var/log/mail | cut -d "+" -f 3|cut -d "@" -f 1 >> ./$FILENAME

This command put all data inside $FILENAME like this, like in rows:

12345

12345

12345

But; notepad opens it up with all data ine one line like this  123451234512345
How can I make sure that my command inserts a return character at the end of data, may be a comma delimeter?

Thanks  in advance


0
Comment
Question by:AbdellahT
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33562514
I use PSPad http://www.pspad.com/ , it recognizes Unix line endings also and can convert them to DOS/Windows style if you want.
0
 

Author Comment

by:AbdellahT
ID: 33562630
I don't think this is going to help me. I have another windows process that need to load the data file and dump it to a table.
Thanks anyways.
0
 
LVL 3

Expert Comment

by:clw3388
ID: 33562667
It's definitively  an Unix line ending issue,  Can you use wordpad instead? It usually recognizes Unix-style line endings
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33562730
How are you getting the info from the Linux system to the Windows system?  FTP ASCII mode will normally convert line endings.
0
 

Author Comment

by:AbdellahT
ID: 33562931
Well, I resolved the issue by telling the SSIS package file connection to consider [SPACE] as the delimeter.
 
Thanks a lot for your help.
0
 
LVL 7

Accepted Solution

by:
rumi78 earned 500 total points
ID: 33562972
Conversion unix-new line (0x0a) to dos-new line (0x0d 0x0a):
sed 's/$/\r/'


try:
grep "to=<no.reply+" /var/log/mail | cut -d "+" -f 3|cut -d "@" -f 1|  sed 's/$/\r/' >> ./$FILENAME

rgds
rumi
0
 

Author Comment

by:AbdellahT
ID: 33563016
"grep "to=<no.reply+" /var/log/mail | cut -d "+" -f 3|cut -d "@" -f 1|  sed 's/$/\r/' >> ./$FILENAME "
I appreciate your suggestion, could you please explain to me what you additions mean?
Thanks
AbdellahT
 
0
 
LVL 7

Expert Comment

by:rumi78
ID: 33563132
sed 's/$/\r/'

It is Regular Expression replace by sed: 's/pattern/replacement/'
pattern is $ (means end of line - virtual character) to be replaced with \r (0x0d char)

In the result when new line character is reached, \r char is appended.

rgds
rumi
0
 
LVL 2

Expert Comment

by:plymelk
ID: 33563892
Windows / DOS systems use a CR/LF (0x0d 0x0a).   Carriage Return / Line Feed
UNIX systems use only the LF (0x0a).   Line Feed
These terms are from the old line printer days.  The Carriage Return told the print head to return to the first character of the line.  The Line Feed told the printer to advance the paper by one line.
Use the sed above like rumi suggested.  It will add the Carriage Return character to each line, as needed by Windows (in some applications).  Many newer applications recognize both end of line methods.
Good Luck.
0
 
LVL 8

Expert Comment

by:allen-davis
ID: 33607696
If your distribution of *nix has the unix2dos command, put
| unix2dos
before the ">>" that does the redirect to the file.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bash script to resolve all hostnames in a list 8 54
how to pick only current date files from a ftp 14 63
AWS CLI issues with Tags 3 86
linux pull logs and export FTP 4 78
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question