Solved

Linux file: Notepad displays all data in one line

Posted on 2010-08-30
10
690 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 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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
Comment Utility
It's definitively  an Unix line ending issue,  Can you use wordpad instead? It usually recognizes Unix-style line endings
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 7

Accepted Solution

by:
rumi78 earned 500 total points
Comment Utility
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
Comment Utility
"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
Comment Utility
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
Comment Utility
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
Comment Utility
If your distribution of *nix has the unix2dos command, put
| unix2dos
before the ">>" that does the redirect to the file.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Powershell Script 8 63
Shell script errors 10 98
Uninstall via powershell 1 55
cron job says it ran, no results 25 93
This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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 this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now