AbdellahT
asked on
Linux file: Notepad displays all data in one line
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
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
I use PSPad http://www.pspad.com/ , it recognizes Unix line endings also and can convert them to DOS/Windows style if you want.
ASKER
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.
Thanks anyways.
It's definitively an Unix line ending issue, Can you use wordpad instead? It usually recognizes Unix-style line endings
How are you getting the info from the Linux system to the Windows system? FTP ASCII mode will normally convert line endings.
ASKER
Well, I resolved the issue by telling the SSIS package file connection to consider [SPACE] as the delimeter.
Thanks a lot for your help.
Thanks a lot for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
"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
I appreciate your suggestion, could you please explain to me what you additions mean?
Thanks
AbdellahT
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
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
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.
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.
If your distribution of *nix has the unix2dos command, put
| unix2dos
before the ">>" that does the redirect to the file.
| unix2dos
before the ">>" that does the redirect to the file.