Sponsored Content
Top Forums Shell Programming and Scripting Remove Last Character of Line Post 36024 by danhodges99 on Monday 19th of May 2003 10:53:08 AM
Old 05-19-2003
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 do a cut of characters 1-x as the string will fluctuate in length!

Thanks.
danhodges99
 

10 More Discussions You Might Find Interesting

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

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

3. UNIX for Advanced & Expert Users

To remove new line character

Hi, I am facing one interesting problem : I have a file which contains data like this 459,|1998-11-047|a |b |c \n efg | d|e | \n 459,|1998-11-047|a \n c|b |c \n efg | d|e | \n Basically what I have to do is , I have to remove all \n which is coming ( enclosed ) in between... (7 Replies)
Discussion started by: shihabvk
7 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
setenv(3C)																setenv(3C)

NAME
setenv(), unsetenv() - add, update or remove an environment variable SYNOPSIS
Parameters envname Points to a string containing the name of an environment variable to be added or altered. This should not be a NULL pointer or null string, and the string should not contain an equal character. envval Points to a string containing the value to be set for the variable envname. overwrite Indicates whether to overwrite the value of envname variable or not, if it already exists. Expected values are non-zero and zero. If the environment variable does not exist in the environment, then the value of this variable is ignored. DESCRIPTION
and functions update the environment of the calling process. If envname does not exist, the function ignores the value of overwrite and adds the variable envname to the environment with the value envval. If envname exists and overwrite is non-zero, then the variable envname is updated with the new value envval. If envname exists and overwrite is zero, then the variable is not updated, and the function is considered to have completed successfully. The function deletes the variable envname from the environment, if it exists. If the envname variable does not exist in the current envi- ronment, the environment is unchanged, and the function is considered to have completed successfully. If the application modifies environ or the pointers to which it points, the behavior of and is undefined. EXTERNAL INFLUENCES
Locale The category determines the interpretation of characters in string as single- and/or multi-byte characters. International Code Set Support Single- and multi-byte character code sets are supported. RETURN VALUE
The and functions return zero on success; otherwise they return and set to indicate the error. ERRORS
If the function fails, is set to one of the following values: Sufficient memory is not available to add a variable or its value to the environment. The envname argument is a null pointer, points to an empty string, or points to a string containing an equal character. If the function fails, is set to the following value: The envname argument is a null pointer, points to an empty string, or points to a string containing an equal character. EXAMPLES
The following code adds a new environment variable to the current environment. The following code updates the variable The following code removes the variable from the current environment. WARNINGS
The and functions manipulate the environment pointed to by environ, and can be used in conjunction with However, envp (the third argument to main) is not changed. The uses to enlarge the environment (see malloc(3C)). After the or function is called, environment variables may not be in alphabetical order. AUTHOR
and were developed by HP. SEE ALSO
exec(2), getenv(3C), malloc(3C), putenv(3C), environ(5), thread_safety(5). STANDARDS CONFORMANCE
setenv(3C)
All times are GMT -4. The time now is 04:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy