Sponsored Content
Top Forums Shell Programming and Scripting remove last 4 characters from a string Post 302373450 by josslate on Friday 20th of November 2009 08:53:18 AM
Old 11-20-2009
remove last 4 characters from a string

I'm tring to remove the last 4 characters from strings in a file i.e.

cat /tmp/test
iwishicouldremovethis
icouldremovethos

so i would end up with the last 4 characters from each of the above i.e.
this
thos

I thought of using cut -c ... but I'm not sure how many characters will precede the important "Last 4 characters i need".

Thanks for your help!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove lasts characters from a string

Hi all, Consider i have a directory /tmp/test and inside this directory i have the following files: 1.svf.tmp 2.svf.tmp 3.svf.tmp How can i remove the last four characters of every file in irder for the directory to be as: 1.svf 2.svf 3.svf I use the following command but id doesn't... (6 Replies)
Discussion started by: chriss_58
6 Replies

2. Shell Programming and Scripting

Remove special characters from string

Hi there, I'd like to write a script that removes any set of character from any string. The first argument would be the string, the second argument would be the characters to remove. For example: $ myscript "My name's Santiago. What's yours?" "atu" My nme's Snigo. Wh's yors? I wrote the... (11 Replies)
Discussion started by: chebarbudo
11 Replies

3. UNIX for Advanced & Expert Users

Remove escape characters from string

Hello all, I have a string var which contains formatting characters at the end, it is a string with EScape sequences at the end of it. How can I remove them so that I only keep the 'real' text? I tried : var1=${var1%%\033[0m} does not seem to do the job .... Please help Thanks (2 Replies)
Discussion started by: gio001
2 Replies

4. UNIX for Dummies Questions & Answers

Remove characters from string variable

I am running a script where one of the variables (the month and year) is input at the command line. What I would like to do is chop off the last few characters of that string to create a new variable, while maintaining the old one. The script is run like this: ./pull_station_v4.csh KYWST... (3 Replies)
Discussion started by: TheSMan5
3 Replies

5. Shell Programming and Scripting

how to remove characters from a string

Hi. for the following line: Var1=${Array} now Array has text as "{hello there}" how do I remove the {} brackets before assigning the string to Var1? Thanks. (3 Replies)
Discussion started by: shadow_boi
3 Replies

6. Shell Programming and Scripting

Remove characters from string

Hi I am new in shell scripting and i want to manipulate a string. I have a string tha looks like: /home/nteath/file.txt I want to remove everything until the last "/" , to keep only the filename. e.g. /home/nteath/file.txt output: file.txt Thanks (2 Replies)
Discussion started by: nteath
2 Replies

7. Shell Programming and Scripting

remove characters from string based on occurrence of a string

Hello Folks.. I need your help .. here the example of my problem..i know its easy..i don't all the commands in unix to do this especiallly sed...here my string.. dwc2_dfg_ajja_dfhhj_vw_dec2_dfgh_dwq desired output is.. dwc2_dfg_ajja_dfhhj it's a simple task with tail... (5 Replies)
Discussion started by: victor369
5 Replies

8. Shell Programming and Scripting

Remove string between two special characters

Hi All, I have a variable like AVAIL="\ BACK:bkpstg:testdb3.iad.expertcity.com:backtest|\ #AUTH:authstg:testdb3.iad.expertcity.com:authiapd|\ TEST:authstg:testdb3.iad.expertcity.com:authiapd|\ " What I want to do here is that If a find # before any entry, remove the entire string... (5 Replies)
Discussion started by: engineermayur
5 Replies

9. Shell Programming and Scripting

How to remove some special characters in a string?

Hi, I have string like this ="Lookup Procedure" But i want the output like this Lookup Procedure =," should be removed. Please suggest me the solution. Regards, Madhuri (2 Replies)
Discussion started by: srimadhuri
2 Replies

10. Shell Programming and Scripting

Outputting characters after a given string and reporting the characters in the row below --sed

I have this fastq file: @M04961:22:000000000-B5VGJ:1:1101:9280:7106 1:N:0:86 GGGGGGGGGGGGCATGAAAACATACAAACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAATACCATGAAAAATATCAACCACACCA +test-1 GGGGGGGGGGGGGGGGGCCGGGGGFF,EDFFGEDFG,@DGGCGGEGGG7DCGGGF68CGFFFGGGG@CGDGFFDFEFEFF:30CGAFFDFEFF8CAF;;8... (10 Replies)
Discussion started by: Xterra
10 Replies
CHARACTERDATA(1)					User Contributed Perl Documentation					  CHARACTERDATA(1)

NAME
XML::DOM::CharacterData - Common interface for Text, CDATASections and Comments DESCRIPTION
XML::DOM::CharacterData extends XML::DOM::Node The CharacterData interface extends Node with a set of attributes and methods for accessing character data in the DOM. For clarity this set is defined here rather than on each object that uses these attributes and methods. No DOM objects correspond directly to CharacterData, though Text, Comment and CDATASection do inherit the interface from it. All offsets in this interface start from 0. METHODS getData and setData (data) The character data of the node that implements this interface. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in a CharacterData node. However, implementation limits may mean that the entirety of a node's data may not fit into a single DOMString. In such cases, the user may call substringData to retrieve the data in appropriately sized pieces. getLength The number of characters that are available through data and the substringData method below. This may have the value zero, i.e., Char- acterData nodes may be empty. substringData (offset, count) Extracts a range of data from the node. Parameters: offset Start offset of substring to extract. count The number of characters to extract. Return Value: The specified substring. If the sum of offset and count exceeds the length, then all characters to the end of the data are returned. appendData (str) Appends the string to the end of the character data of the node. Upon success, data provides access to the concatenation of data and the DOMString specified. insertData (offset, arg) Inserts a string at the specified character offset. Parameters: offset The character offset at which to insert. arg The DOMString to insert. deleteData (offset, count) Removes a range of characters from the node. Upon success, data and length reflect the change. If the sum of offset and count exceeds length then all characters from offset to the end of the data are deleted. Parameters: offset The offset from which to remove characters. count The number of characters to delete. replaceData (offset, count, arg) Replaces the characters starting at the specified character offset with the specified string. Parameters: offset The offset from which to start replacing. count The number of characters to replace. arg The DOMString with which the range must be replaced. If the sum of offset and count exceeds length, then all characters to the end of the data are replaced (i.e., the effect is the same as a remove method call with the same range, followed by an append method invocation). perl v5.8.0 2000-01-31 CHARACTERDATA(1)
All times are GMT -4. The time now is 08:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy