Sponsored Content
Top Forums Shell Programming and Scripting How to remove a semi-repeating character in position 1 of a file Post 302560618 by right_coaster on Friday 30th of September 2011 11:10:47 AM
Old 09-30-2011
How to remove a semi-repeating character in position 1 of a file

My file is in a good column format but several lines in the file begin with a zero. I'm in KSH and looking for a command to remove this zero and keep the text next to it. I don't want any of the zeros in the other columns removed.

Below is a snip from the file... all I need to do is remove that zero at the beginning of several lines. I can't seem to get cut or sed to work for me.

Contents of file:
Code:
 
0AAC            08/19/2011  14:38  03.40
 AAL            08/20/2010  09:21  01.20
 ABK            08/20/2010  09:22  01.11
0ABR            06/10/2011  11:27  01.45
 ACM            08/20/2010  09:23  01.10
 ADHOCREC       05/17/2011  14:01  01.55
 ADW            02/03/2011  11:14  01.24
 AEA            08/18/2011  14:36  01.13
 AGL            08/20/2010  09:27  01.88
0AGM            08/20/2010  09:28  01.13
 AGT            07/06/2011  08:57  01.91
 AGY            08/22/2011  15:30  01.93
 AHM            08/20/2010  09:38  01.10
 AJA            08/20/2010  09:39  01.16
 AJB            08/20/2010  09:40  01.15
0AJO            08/20/2010  09:41  01.36
0AJP            08/20/2010  09:42  01.12
 ALB            08/20/2010  09:43  01.26
0ALS            08/20/2010  09:43  01.10
 AMC            08/20/2010  09:43  01.20
 AMQ            04/07/2011  11:14  01.08
 AMY            08/20/2010  09:44  01.13
 APM            04/19/2011  09:03  02.46
 ARC            08/20/2010  09:50  01.08
0ASA            04/05/2011  13:56  01.28
 ASE            06/15/2011  10:34  01.44

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert character in a specific position of a file

Hi, I need to add Pipe (|) at 5th and 18th position of all records a file. How can I do this? I tried to add it at 5th position using the below code. It didnt work. Please help!!! awk '{substr($0,5,1) ~ /|/}{print}' $input_file > $temp_file (1 Reply)
Discussion started by: gpaulose
1 Replies

2. Shell Programming and Scripting

Remove repeating pattern from beginning of file names.

I want a shell script that will traverse a file system starting at specific path. And look at all file names for repeating sequences of and remove them from the file name. The portion of the name that gets removed has to be a repeating sequence of the same characters. So the script would... (3 Replies)
Discussion started by: z399y
3 Replies

3. UNIX for Dummies Questions & Answers

Sort file by character position

Hi! I need to sort file by certain column (column position from-to). I tried sort command, but it works wrong. Example: 0001 5214521 0148 6712145 I need to sort this 2 lines by values from position 9 to 12 (bold) Output: 0148 6712145 0001 5214521 Is there any way how to do this? (2 Replies)
Discussion started by: nadinnne
2 Replies

4. Shell Programming and Scripting

How to find character position in file?

how to find character positionin file? i.e string = "123X568" i want to find the position of character "X". Thanks (6 Replies)
Discussion started by: LiorAmitai
6 Replies

5. UNIX for Dummies Questions & Answers

Using sed command to remove multiple instances of repeating headers in one file?

Hi, I have catenated multiple output files (from a monte carlo run) into one big output file. Each individual file has it's own two line header. So when I catenate, there are multiple two line headers (of the same wording) within the big file. How do I use the sed command to search for the... (1 Reply)
Discussion started by: rebazon
1 Replies

6. Linux

Linux script to remove a character in a file based on position.

Greetings, We have a requirement where we need to loop in a fixed width file in linux and remove a character based on a position for every record. It would highly appreciate if someone can help to automate this. Appreciate your time and help! Regards (3 Replies)
Discussion started by: mailme0205
3 Replies

7. Shell Programming and Scripting

Find position of character in multiple strings in a file

Greetings. I have a file with information like this: AMNDHRKEOEU?AMNDHRKEOEU?AMNDHRKEOEU?AMNDHRKEOEU? AMNDHRKEEU?AMNDHREOEU? AMNDHREU?AHRKEOEU?AMNDHRKEU?AMNDKEOEU? What I need to extract is the position, in every line, of every occurrence of '?' A desired output would be something... (6 Replies)
Discussion started by: Twinklefingers
6 Replies

8. Emergency UNIX and Linux Support

Replace nth position character of all the lines in file

I want to replace 150th character of all the lines in a file using sed or awk... searched the forums but didn't find exact answer (9 Replies)
Discussion started by: greenworld123
9 Replies

9. Shell Programming and Scripting

Remove " character from 25th position in file

Hi All, I want to remove " character if present in position 25th in CSV file. Each field in CSV file is separated by , and enclosed in "" (enclosed using double quotes) For example "1","2","3",........."123 Tom " is Good boy","26",........"45" Where "1" first position character, ...... 25th... (8 Replies)
Discussion started by: lancesunny
8 Replies

10. 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
HTML::Microformats::Datatype::Interval(3pm)		User Contributed Perl Documentation	       HTML::Microformats::Datatype::Interval(3pm)

NAME
HTML::Microformats::Datatype::Interval - concrete periods of time SYNOPSIS
my $interval = HTML::Microformats::Datatype::Interval->new($span); print "$interval "; DESCRIPTION
Constructors "$i = HTML::Microformats::Datatype::Interval->new($span)" Creates a new HTML::Microformats::Datatype::Interval object. $span is a DateTime::Span object. "$i = HTML::Microformats::Datatype::Interval->parse($string, $elem, $context)" Creates a new HTML::Microformats::Datatype::Interval object. $string is an interval represented in ISO 8601 format, for example: '2010-01-01/P1Y' or '2010-01-01/2011-01-01'. $elem is the XML::LibXML::Element being parsed. $context is the document context. This constructor supports a number of experimental microformat interval patterns. e.g. <div class="interval"> <span class="d">4</span> days starting from <abbr class="start" title="2010-01-01">2010</abbr> </div> Public Methods "$span = $i->span" Returns a DateTime::Span object. "$span = $i->to_string" Returns an ISO 8601 formatted string representing the interval. "$d->datatype" Returns an the RDF datatype URI representing the data type of this literal. Function "compare($a, $b)" Compares intervals $a and $b. Return values are as per 'cmp' (see perlfunc). This function is not exported by default. Can also be used as a method: $a->compare($b); BUGS
Please report any bugs to <http://rt.cpan.org/>. SEE ALSO
HTML::Microformats, HTML::Microformats::Datatype, DateTime::Span. AUTHOR
Toby Inkster <tobyink@cpan.org>. COPYRIGHT
Copyright 2008-2011 Toby Inkster This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. perl v5.14.2 2011-12-06 HTML::Microformats::Datatype::Interval(3pm)
All times are GMT -4. The time now is 09:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy