Sponsored Content
Top Forums Shell Programming and Scripting How to remove a semi-repeating character in position 1 of a file Post 302560663 by Scott on Friday 30th of September 2011 12:33:15 PM
Old 09-30-2011
Tiny correction (assuming the alignment is to be maintained)...
Code:
sed 's/^0/ /' File

Or removed:
Code:
sed 's/^[0 ]//' File

If you want to remove multiple leading zeros:
Code:
sed 's/^0[0]*/ /' File

This User Gave Thanks to Scott For This Post:
 

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
File::Type(3pm) 					User Contributed Perl Documentation					   File::Type(3pm)

NAME
File::Type - determine file type using magic SYNOPSIS
my $ft = File::Type->new(); # read in data from file to $data, then my $type_from_data = $ft->checktype_contents($data); # alternatively, check file from disk my $type_from_file = $ft->checktype_filename($file); # convenient method for checking either a file or data my $type_1 = $ft->mime_type($file); my $type_2 = $ft->mime_type($data); DESCRIPTION
File::Type uses magic numbers (typically at the start of a file) to determine the MIME type of that file. File::Type can use either a filename, or file contents, to determine the type of a file. METHODS
new Returns a new File::Type object. mime_type($argument) Takes either data or a filename, determines what it is, and passes the argument through to the relevant method below. If the argument is a directory, returns undef. checktype_filename($filename) Opens $filename (if possible; if not, returns undef) and returns the MIME type of the file. checktype_contents($data) Matches $data against the magic database criteria and returns the MIME type of the file. TODO
* Add additional magic match criteria BUGS
None known. NOTES Some magic definitions in the mime-magic file used in the creation of this module vary from those in other apps (eg image/x-png not image/png). SEE ALSO
File::MMagic and File::MimeInfo perform the same job, but have a number of problems that led to the creation of this module. File::MMagic inlines a copy of the magic database, and uses a DATA filehandle, which causes problems when running under mod_perl. File::MimeInfo uses an external magic file, and relies on file extensions rather than magic to determine the mime type. As a result, File::Type uses a seperate module and script to create the code at the core of this module, which means that there is no need to include a magic database at all, and that it is safe to run under mod_perl. File::Type::Builder, which generates the code at the heart of this module. ACKNOWLEDGMENTS
File::Type is built from a mime-magic file from cleancode.org. The original can be found at <http://clean- code.org/cgi-bin/viewcvs.cgi/email/mime-magic.mime?rev=1.1.1.1>. AUTHOR
Paul Mison <pmison@fotango.com> COPYRIGHT
Copyright 2003-2004 Fotango Ltd. LICENSE
Licensed under the same terms as Perl itself. perl v5.8.8 2004-10-08 File::Type(3pm)
All times are GMT -4. The time now is 03:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy