Sponsored Content
Full Discussion: UNIX file with Newlines
Top Forums Shell Programming and Scripting UNIX file with Newlines Post 303031438 by victory on Thursday 28th of February 2019 09:20:21 AM
Old 02-28-2019
UNIX file with Newlines

Hi Friends,

I have a data file with new lines.

How to remove the newlines and should be showed in one line.

I tried using the command

Code:
tr -d '\n' filename

sed 's/\n//g' file name

Ex: 1 abc hyd is actual record
but in our scenario showing it as
Code:
1 abc
hyd

this record should be like as follows.

Code:
1 abc hyd

it's not working.

Could you please help me out to overcome the issue.

Thanks in Advance!




Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 02-28-2019 at 10:32 AM.. Reason: AddedCODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing inserted newlines from a fileld of fixed width file.

Hi champs! I have a fixed width file in which the records appear like this 11111 <fixed spaces such as 6> description for 11111 <fixed spaces such as 6> some more field to the record of 11111 22222 <fixed spaces such as 6> description for 22222 <fixed spaces such as 6> some more field to the... (8 Replies)
Discussion started by: enigma_1
8 Replies

2. Shell Programming and Scripting

Transpose with two newlines as delimiter

Hi Guys, I have data in a file as follows: a 1 2 3 b 4 5 6 a 6 7 8 a 4 7 9 b 6 8 5 c 0 8 7 So the number of rows which have data is variable (2 for the first group, one for the second group and three for the third group), but the delimiters between the... (10 Replies)
Discussion started by: npatwardhan
10 Replies

3. Shell Programming and Scripting

Padding lines in a file with newlines

Hi Guys, I have a file as shown below: 55 6 77 8 88 98 7 85 45 544 1 33 32 13 13 (5 Replies)
Discussion started by: npatwardhan
5 Replies

4. UNIX for Dummies Questions & Answers

finding string in very long file without newlines

What's the best way to find a string in a very long file without newlines in Unix? The standard utility I'm aware of for finding a string in a single file is grep, but for a long file without newlines, I think the output is just going to be the input. I suppose I could use sed to replace the... (5 Replies)
Discussion started by: aaronpoley
5 Replies

5. Shell Programming and Scripting

'for LINE in $(cat file)' breaking at spaces, not just newlines

Hello. I'm making a (hopefully) simple shell script xml parser that outputs a file I can grep for information. I am writing it because I have yet to find a command line utility that can do this. If you know of one, please just stop now and tell me about it. Even better would be one I can input... (10 Replies)
Discussion started by: natedawg1013
10 Replies

6. Shell Programming and Scripting

Extract pattern before two newlines

Hi All, My file looks like this: 1 2 3 3 4 5 6 7 8 8 7 6 3 4 5 3 6 7 3 4 5 1 2 4 3 4 6 2 4 6 As you can see there are two newlines after the next pattern of numbers begin. (4 Replies)
Discussion started by: shoaibjameel123
4 Replies

7. Shell Programming and Scripting

removing newlines after a certain word.

Hello! This is my first post here. I have a file with text like: A</title> B C</title> D I need to format it to: AB CD I am trying to use sed: sed 's/<//title>\n/ /g' file > newfile to delete </title> and the newline character, but the file is unchanged because there are... (3 Replies)
Discussion started by: DaytonCPS
3 Replies

8. UNIX for Dummies Questions & Answers

Remove newlines

Hi buddy's my file are like this: s.no,name,band,sal 1,"suneel",,10 2,"bargav sand",,20 30," ebdug gil",,4 but i want s.no,name,band,sal 1,"suneel",,10 2,"bargav sand",,20 30,"ebdug gil",,4 any command or Shell script for this. please help me it's urgent to implement (33 Replies)
Discussion started by: Suneelbabu.etl
33 Replies

9. UNIX for Beginners Questions & Answers

Remove newlines and carriage return from a csv file using UNIX

I need to remove new lines and carriage returns from csv file. Is there anything other than sed and gwak by which we could achieve this ? Any suggestions ? (3 Replies)
Discussion started by: A_Gaddale
3 Replies

10. Shell Programming and Scripting

File formatting with newlines

Hi All - I am in need of some help in formating the below file Requirement - 1) replace newlines with space 2) replace '#~# ' with newline ----------------------- sample inputfile a I|abc|abc|aaa#~# I|sddddd|tya|dfg sfd ssss#~# I|tya1|tya2|dfg|sfd|aaa#~#... (5 Replies)
Discussion started by: J1nx007
5 Replies
SHAR(1net)							  Wang Institute							SHAR(1net)

NAME
shar - create file storage archive for extraction by /bin/sh SYNOPSIS
shar [-abcmsuv] [-p prefix] [-d delim] files > archive DESCRIPTION
shar prints its input files with special command lines around them to be used by the shell, /bin/sh , to extract the files later. The out- put can be filtered through the shell to recreate copies of the original files. shar allows directories to be named, and shar prints the necessary commands (mkdir & cd) to create new directories and fill them. shar will not allow existing files to be over-written; such files must be removed by the user extracting the files. OPTIONS
-a All the options. The options: -v -c -b -p <tab>X are implied. -b Extract files into basenames so that files with absolute path names are put into the current directory. This option has strange effects when directories are archived. -c Check file size on extraction by counting characters. An error message is reported to the person doing the extraction if the sizes don't match. One reason why the sizes may not match is that shar will append a newline to complete incomplete last lines; shar prints a message that mentions added newlines. Another reason why the sizes may not match is that some network mail programs remove non-whitespace control characters. shar prints a message that mentions control characters to the extractor. -d Use this as the ``end of file'' delimiter instead of the default. The only reason to change it is if you suspect a file contains the default delimiter: SHAR_EOF. -m Reset the exact protection modes of files when they are extracted (using the chmod program). By default, the extractor's default file modes are used, and executable files (e.g., shell scripts) are made executable. -p Use this as the prefix to each line of the archived files. This is to make sure that special characters at the start of lines are not eaten up by programs like mailers. If this option is used, the files will be extracted with the stream editor sed rather than cat so it is more efficient and portable to avoid setting the prefix, though perhaps less safe if you don't know what is in the files. -s Silent running. All checking and extra output is inhibited. -u Archive the input files with the uuencode format for later extraction with uudecode. This will allow you to send files with control characters in them, but will slow down the extracting. You must be sure that the receiving party has access to uudecode. -v Print verbose feedback messages about what shar is doing to be printed during extraction. Sizes of plain files are echoed to allow a simple validity check. SEE ALSO
sh(1), tar(1), cpio(1), tp(1), uuencode(1), uudecode(1) fpack(1) is a plain-file packer useful for UNIX and MSDOS AUTHOR
Gary Perlman (based on a shell version by James Gosling, with additions motivated by many people on the UNIX network: Derek Zahn, Michael Thompson, H. Morrow Long, Fred Avolio, Gran Uddeborg, Chuck Wegrzyn, nucleus!randy@TORONTO, & Bill McKeeman) LIMITATIONS
shar does not know anything about links between files. UNIX User's Manual March 4, 1986 SHAR(1net)
All times are GMT -4. The time now is 03:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy