Sponsored Content
Top Forums Shell Programming and Scripting remove the first and last character of a string Post 302594720 by balajesuri on Wednesday 1st of February 2012 04:41:21 AM
Old 02-01-2012
This should fix it.
Code:
sed 's/^.\(.*\).$/\1/' inputfile

This User Gave Thanks to balajesuri For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove box like special character from end of string

Hi All, How to remove a box like special character which appears at the end of a string/line/record. I have no clue what this box like special character is. It is transparent square like box. This appears in a .DAT file at the end of header. I'm to compare a value in header with a parameter.... (16 Replies)
Discussion started by: Qwerty123
16 Replies

2. Shell Programming and Scripting

shell script to remove the last character(.) of a string

hi I have a list of words in a text file. these words are appended by "." at their end. They look something like this. word1. word2. word3. word4. word5. I need to remove the last character "." from all the words. The output must look something like this. word1 word2 word3... (7 Replies)
Discussion started by: ss3944
7 Replies

3. Shell Programming and Scripting

How to remove the first character on a string in a variable

Hi all, Does anyone know how to code in ksh that will remove the first character in a string variable and replace that variable without the first character? Example: var1=ktest1 will become var1=test1 var2=rtest2 will become var2=test2 Need help please. (10 Replies)
Discussion started by: ryukishin_17
10 Replies

4. Shell Programming and Scripting

How to remove last character in a string read from file

Hello, The last character is a comma , I have tried the following: sed -e 's/\,$//' filename-to-read however - there are still commas at the end of each line...:confused: (5 Replies)
Discussion started by: learning
5 Replies

5. Shell Programming and Scripting

Sed is doing my head in! How do you remove the first character of a string?

Hello! Please bare with me, I'm a total newbie to scripting. Here's the sudo code of what I'm trying to do: Get file name Does file exist? If true get length of file name get network id (this will be the last 3 numbers of the file name) loop x 2 If... (1 Reply)
Discussion started by: KatieV
1 Replies

6. Shell Programming and Scripting

remove all occurrences of a character at the beginning of a string

Hi there, i need some help to remove all occurrences of a certain character at the beginning of a string. Example: my string is 00102030 and i want to remove all zeros from beginning of string so the result is 102030 (3 Replies)
Discussion started by: gigagigosu
3 Replies

7. Shell Programming and Scripting

Bash: How to remove the last character of a string?

In bash, how can one remove the last character of a string? In perl, the chop function would remove the last character. However, I do not know how to do the same job in bash. Many thanks in advance. (12 Replies)
Discussion started by: LessNux
12 Replies

8. Shell Programming and Scripting

Remove 3rd character from the end of a random-length string

Hi, I hope someone can share there scripting fu on my problem, I would like to delete the 3rd character from a random length of string starting from the end Example Output Hope you can help me.. Thanks in advance.. (3 Replies)
Discussion started by: jao_madn
3 Replies

9. Shell Programming and Scripting

gawk to remove last character in a line or string

I am outputting a line like this print $2 "/" $4The last character though is a ":" and I want to remove it. Is there any neat way to remove it? Or am I forced to do something like this: print $2 "/" substr($4, 1, length($4) - 1)Thanks. (6 Replies)
Discussion started by: benalt
6 Replies

10. UNIX for Beginners Questions & Answers

Remove string between number and character

hello ! I have to remove string between a number and set of characters. For example, 35818 -stress - - -stress - - - - - - DB-3754 44412 caul kid notify DB-3747 54432 roberto -, notify DB-3725 55522 aws _ _int _ _classified 2_a _a 2_m _m 2_classified 2_search... (7 Replies)
Discussion started by: ManoharMa
7 Replies
Number::RecordLocator(3pm)				User Contributed Perl Documentation				Number::RecordLocator(3pm)

NAME
Number::RecordLocator - Encodes integers into a short and easy to read and pronounce "locator string" SYNOPSIS
use Number::RecordLocator; my $generator = Number::RecordLocator->new(); my $string = $generator->encode("123456"); # $string = "5RL2"; my $number = $generator->decode($string); # $number = "123456"; DESCRIPTION
"Number::RecordLocator" encodes integers into a 32 character "alphabet" designed to be short and easy to read and pronounce. The encoding maps: 0 to O 1 to I S to F B to P With a 32 bit encoding, you can map 33.5 million unique ids into a 5 character code. This certainly isn't an exact science and I'm not yet 100% sure of the encoding. Feedback is much appreciated. new Instantiate a new "Number::RecordLocator" object. Right now, we don't actually store any object-specific data, but in the future, we might. init Initializes our integer to character and character to integer mapping tables. encode INTEGER Takes an integer. Returns a Record Locator string. decode STRING Takes a record locator string and returns an integer. If you pass in a string containing an invalid character, it returns undef. canonicalize STRING To compare a Record Locator string with another you can do: print "ALWAYS TRUE " if $generator->decode("B0") == $generator->decode("PO"); However, this method provides an alternative: my $rl_string = $generator->encode(725); print "ALWAYS TRUE " if $generator->canonicalize("b0") eq $rl_string; print "ALWAYS TRUE " if $generator->canonicalize("BO") eq $rl_string; print "ALWAYS TRUE " if $generator->canonicalize("P0") eq $rl_string; print "ALWAYS TRUE " if $generator->canonicalize("po") eq $rl_string; This is primarily useful if you store the record locator rather than just the original integer and don't want to have to decode your strings to do comparisons. Takes a general Record Locator string and returns one with character mappings listed in "DESCRIPTION" applied to it. This allows string comparisons to work. This returns "undef" if a non-alphanumeric character is found in the string. BUGS AND LIMITATIONS
No bugs have been reported. Please report any bugs or feature requests to "bug-number-recordlocator@rt.cpan.org", or through the web interface at <http://rt.cpan.org>. AUTHOR
Jesse Vincent "<jesse@bestpractical.com>" LICENCE AND COPYRIGHT
Copyright (c) 2006, Best Practical Solutions, LLC. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. perl v5.10.0 2009-08-13 Number::RecordLocator(3pm)
All times are GMT -4. The time now is 02:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy