Sponsored Content
Full Discussion: To remove new line character
Top Forums UNIX for Advanced & Expert Users To remove new line character Post 80899 by reborg on Friday 12th of August 2005 08:42:06 PM
Old 08-12-2005
Code:
# cat file.txt
|a|b
c|d|
|e|f|i|
|h|i|j|


sed 'N; s/\n[       ]*\([^|]\)/\1/g' file.txt
|a|bc|d|
|e|f|i|
|h|i|j|

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove Last Character of Line

Hi, I need to put the single line contents of a file into a variable, but remove the last character, for example the file would have this sort of contents: 2;4;3;10;67;54;96; And I want the variable to be: 2;4;3;10;67;54;96 (notice the last ";" has gone). Unfortunately I can't just... (4 Replies)
Discussion started by: danhodges99
4 Replies

2. UNIX for Dummies Questions & Answers

Trying to remove single character from a line

Here is a sample code grep '903' -i user.txt | tail -2 | awk '{print $2}' | sed 's/B//g' the input file has data as such 903-xxx-xxxxB 903-xxx-xxxxB It is a dialer file i want to remove the "B" any help thanks (5 Replies)
Discussion started by: Iz3k34l
5 Replies

3. Shell Programming and Scripting

sed: remove first character from particular line

Hello Experts, I have a file "tt.txt" which is like: #a1=a2 b1=b2 #c1=c2 I need to remove the pound (#) sign from a particular line. In this case let us assume it's 3rd line : "#c1=c2" I can do it through: sed "s/#c1=c2/c1=c2/" tt.txtbut it is possible that I may not know the value... (6 Replies)
Discussion started by: hkansal
6 Replies

4. 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

5. Shell Programming and Scripting

remove line feeds followed by character

Hi everyone, I'm very new to using sed, run through some tutorials and everything but I've hit a problem that I'm unable to solve by myself. I need to remove all linefeeds that are followed by a particular character (in this case a semicolon). So basically, all lines starting with a semicolon... (5 Replies)
Discussion started by: fluffdasheep
5 Replies

6. Shell Programming and Scripting

How to remove , if first character on line

Hi, I have a file with lines such as the below. I want to remove the comma only if it is the first character on a line. I can't work out how to do this using sed. *ELSET, ELSET=WHEEL_TD2 63, 64, 65, 72, 82, 88, 89, 92, 120, 121, 152, 181, 190, 221, 252, 259 , 260, 282, 283, 285, 286,... (2 Replies)
Discussion started by: carlr
2 Replies

7. Shell Programming and Scripting

Remove the last character (,) for every line in a file

Good afternoon: im working wih 2 files to find differences and use the cmp command cmp file1 file2 file1 file2 are are diifferent char 302 line1 i found what the difference is with the sed command and that is the file1 at the end of every line has a (,) (comma) character. i.e sed -n... (4 Replies)
Discussion started by: alexcol
4 Replies

8. UNIX for Dummies Questions & Answers

Remove last character in each line

Hi guys, Does anyone know how to remove the last character in each of the line? This is what I have: ABCDE.1 GLSJD.2 HIJPL.2 HKAGB.3 IUBWQ.1 What I want (remove the dot and number): ABCDE GLSJD HIJPL HKAGB IUBWQ I tried to use this: sed 's/.*//' But I'm not sure if that is... (3 Replies)
Discussion started by: narachaid
3 Replies

9. UNIX for Dummies Questions & Answers

How to remove $ or new line character in a file?

Hi All, Could any one suggest how to remove $ symbol in a text file when i am opening in vi editor. Scenario; For example iam having a file name aaa.txt the data inside the file is like sample name when i am opening in vi editor The same file resembles like below when i am... (1 Reply)
Discussion started by: Chandru_Raj
1 Replies

10. Shell Programming and Scripting

Remove character from a column in each line

Hi, I am a newbie to shell scripting (.sh). Please guide me on how to do the below issue. My input file has below data. I want to remove $ sysmbol from the fourth column of each line. (ie, between 4th and 5th pipe symbol) ABC25160|51497|06/02/2010|$32,192.07|MARK|$100|A... (3 Replies)
Discussion started by: rsreejithmenon
3 Replies
DateFormat(3)						User Contributed Perl Documentation					     DateFormat(3)

NAME
Log::Log4perl::DateFormat - Log4perl advanced date formatter helper class SYNOPSIS
use Log::Log4perl::DateFormat; my $format = Log::Log4perl::DateFormat->new("HH:mm:ss,SSS"); # Simple time, resolution in seconds my $time = time(); print $format->format($time), " "; # => "17:02:39,000" # Advanced time, resultion in milliseconds use Time::HiRes; my ($secs, $msecs) = Time::HiRes::gettimeofday(); print $format->format($secs, $msecs), " "; # => "17:02:39,959" DESCRIPTION
"Log::Log4perl::DateFormat" is a low-level helper class for the advanced date formatting functions in "Log::Log4perl::Layout::PatternLayout". Unless you're writing your own Layout class like Log::Log4perl::Layout::PatternLayout, there's probably not much use for you to read this. "Log::Log4perl::DateFormat" is a formatter which allows dates to be formatted according to the log4j spec on http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html which allows the following placeholders to be recognized and processed: Symbol Meaning Presentation Example ------ ------- ------------ ------- G era designator (Text) AD y year (Number) 1996 M month in year (Text & Number) July & 07 d day in month (Number) 10 h hour in am/pm (1~12) (Number) 12 H hour in day (0~23) (Number) 0 m minute in hour (Number) 30 s second in minute (Number) 55 S millisecond (Number) 978 E day in week (Text) Tuesday D day in year (Number) 189 F day of week in month (Number) 2 (2nd Wed in July) w week in year (Number) 27 W week in month (Number) 2 a am/pm marker (Text) PM k hour in day (1~24) (Number) 24 K hour in am/pm (0~11) (Number) 0 z time zone (Text) Pacific Standard Time Z RFC 822 time zone (Text) -0800 ' escape for text (Delimiter) '' single quote (Literal) ' For example, if you want to format the current Unix time in "MM/dd HH:mm" format, all you have to do is this: use Log::Log4perl::DateFormat; my $format = Log::Log4perl::DateFormat->new("MM/dd HH:mm"); my $time = time(); print $format->format($time), " "; While the "new()" method is expensive, because it parses the format strings and sets up all kinds of structures behind the scenes, followup calls to "format()" are fast, because "DateFormat" will just call "localtime()" and "sprintf()" once to return the formatted date/time string. So, typically, you would initialize the formatter once and then reuse it over and over again to display all kinds of time values. Also, for your convenience, the following predefined formats are available, just as outlined in the log4j spec: Format Equivalent Example ABSOLUTE "HH:mm:ss,SSS" "15:49:37,459" DATE "dd MMM yyyy HH:mm:ss,SSS" "06 Nov 1994 15:49:37,459" ISO8601 "yyyy-MM-dd HH:mm:ss,SSS" "1999-11-27 15:49:37,459" APACHE "[EEE MMM dd HH:mm:ss yyyy]" "[Wed Mar 16 15:49:37 2005]" So, instead of passing Log::Log4perl::DateFormat->new("HH:mm:ss,SSS"); you could just as well say Log::Log4perl::DateFormat->new("ABSOLUTE"); and get the same result later on. Known Shortcomings The following placeholders are currently not recognized, unless someone (and that could be you :) implements them: F day of week in month w week in year W week in month k hour in day K hour in am/pm z timezone (but we got 'Z' for the numeric time zone value) Also, "Log::Log4perl::DateFormat" just knows about English week and month names, internationalization support has to be added. COPYRIGHT AND LICENSE
Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess <cpan@goess.org>. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.1 2010-02-07 DateFormat(3)
All times are GMT -4. The time now is 08:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy