Sponsored Content
Top Forums Shell Programming and Scripting HOW: Dealing with new line character Wiindows-vs-UNIX Post 302519477 by shekharjchandra on Wednesday 4th of May 2011 06:14:31 AM
Old 05-04-2011
Java HOW: Dealing with new line character Wiindows-vs-UNIX

Hi
I am getting this similar below lines, by splitting one big file by using the code in my shell script

Line is:-
HTML Code:
111111111|  +.00|12/11/04|12/11/05|n
222222222|  +.00|12/11/05|12/11/06|n
333333333|  +.00|12/11/06|10/11/07|n
Code is:-
Code:
 
...
...
...
nawk -F"|" -v v1="${v_pno}" -v v2="${v_nid}" -v v3="${v_ipath}" '{
fn=v3 "/AAA_" (length($1)==2?"BBBB":"CCCCC") "_" v1 "_" v2 ".txt"
print > fn
}' ${v_ipath}/${v_pno}_spoolfile.txt
if [ $? -eq 0 ]
then
  sed 's/[ ]*$/\n/' ${v_ipath}/AAA_CCCCC_${v_pno}_${v_nid}.txt > ${v_ipath}/dummy.txt
  mv ${v_ipath}/dummy.txt ${v_ipath}/AAA_CCCCC_${v_pno}_${v_nid}.txt
...
...
...

But I want in following format
HTML Code:
111111111|  +.00|12/11/04|12/11/05|n
222222222|  +.00|12/11/05|12/11/06|n
333333333|  +.00|12/11/06|10/11/07|n
When I open the file in UNIX vi editor I am getting in required format i.e.
HTML Code:
111111111|  +.00|12/11/04|12/11/05|n
222222222|  +.00|12/11/05|12/11/06|n
333333333|  +.00|12/11/06|10/11/07|n
But if the same file I open in Windows I am getting in this format
111111111| +.00|12/11/04|12/11/05|n^222222222| .00|12/11/05|12/11/06|n^
333333333| +.00|12/11/06|10/11/07|n

In the place of ^ character I am getting box type character (Which I am not able to show in this editor, so I replaced with ^ symbol)

Any other good way of getting is highly appreciable
Regards
jc
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk not working due to missing new line character at last line of file

Hi, My awk program is failing. I figured out using command od -c filename that the last line of the file doesnt end with a new line character. Mine is an automated process because of this data is missing. How do i handle this? I want to append new line character at the end of last... (2 Replies)
Discussion started by: pinnacle
2 Replies

2. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

3. Solaris

Line too long error Replace string with new line line character

I get a file which has all its content in a single row. The file contains xml data containing 3000 records, but all in a single row, making it difficult for Unix to Process the file. I decided to insert a new line character at all occurrences of a particular string in this file (say replacing... (4 Replies)
Discussion started by: ducati
4 Replies

4. UNIX for Dummies Questions & Answers

Need help removing last character of every line if certain character

I need help removing the last character of every line if it is a certain character. For example I need to get rid of a % character if it is in the last position. Input: aaa% %bbb ccc d%dd% Output should be: aaa %bbb ccc d%dd I tried this but it gets rid of all of the % characters.... (5 Replies)
Discussion started by: raptor25
5 Replies

5. Shell Programming and Scripting

Unix-problem of New line character

Hi All, "Please read the below information carefully." i have tried the below code for counting the number of lines present in text file ignoring blank lines #! /bin/bash clear rdCount=0; while read myline do if ; then echo "line is empty" else echo $myline let... (10 Replies)
Discussion started by: aish11
10 Replies

6. Shell Programming and Scripting

Unix command to select first few characters and last character of a line

I have a huge file and I want to select first 10 charcters and last 2 characters of everyline and than will filter the unique line. I know, it must be easy bt I am new to unix scripting:) Ex. I have file as below and need to e3kbaird and last 2 characters. and than unique records. ... (3 Replies)
Discussion started by: Sanjeev Yadav
3 Replies

7. Shell Programming and Scripting

Sed: delete on each line before a character and after a character

Hi there, A total sed noob here. Is there a way using sed to delete everything before a character AND after another character on each line in a file? The deletion should also delete the indicating characters(here: an opening and a closing parenthesis). The original file would look like... (3 Replies)
Discussion started by: bnbsd
3 Replies

8. Shell Programming and Scripting

Read character by character in line in which space is also included

Hi friend, I have one file , and i want to read that file character by character. I need this script in ksh. while using read option with -n1 am getting error. while read -n1 c read has bad option And if i am using below script, then if in a line has space like this ( Pallvi mahajan)... (10 Replies)
Discussion started by: pallvi_mahajan
10 Replies

9. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies
curs_ins_wstr(3X)														 curs_ins_wstr(3X)

NAME
ins_wstr, ins_nwstr, wins_wstr, wins_nwstr, mvins_wstr, mvins_nwstr, mvwins_wstr, mvwins_nwstr - insert a wide-character string into a curses window SYNOPSIS
#include <curses.h> int ins_wstr(const wchar_t *wstr); int ins_nwstr(const wchar_t *wstr, int n); int wins_wstr(WINDOW *win, const wchar_t *wstr); int wins_nwstr(WINDOW *win, const wchar_t *wstr, int n); int mvins_wstr(int y, int x, const wchar_t *wstr); int mvins_nwstr(int y, int x, const wchar_t *wstr, int n); int mvwins_wstr(WINDOW *win, int y, int x, const wchar_t *wstr); int mvwins_nwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n); DESCRIPTION
These routines insert a wchar_t character string (as many characters as will fit on the line) before the character under the cursor. All characters to the right of the cursor are shifted right, with the possibility of the rightmost characters on the line being lost. No wrap- ping is performed. The cursor position does not change (after moving to y, x, if specified). The four routines with n as the last argu- ment insert a leading substring of at most n wchar_t characters. If n is less than 1, the entire string is inserted. If a character in wstr is a tab, newline, carriage return or backspace, the cursor is moved appropriately within the window. A newline al- so does a clrtoeol before moving. Tabs are considered to be at every eighth column. If a character in wstr is another control character, it is drawn in the ^X notation. Calling win_wch after adding a control character (and moving to it, if necessary) does not return the con- trol character, but instead returns a character in the ^-representation of the control character. NOTES
Note that all but wins_nwstr may be macros. If the first character in the string is a nonspacing character, these functions will fail. XSI does not define what will happen if a non- spacing character follows a control character. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. SEE ALSO
curses(3X), curs_insstr(3X), curs_in_wch(3X), curs_ins_wch(3X). curs_ins_wstr(3X)
All times are GMT -4. The time now is 10:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy