Sponsored Content
Top Forums Shell Programming and Scripting Removing last character from each line of file Post 62650 by vgersh99 on Friday 18th of February 2005 09:16:23 AM
Old 02-18-2005
sed -e 's/\(.*\).$/\1/g' file

As it's been outlined in the thread, transfer/ftp your files in ASCII mode.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing character from list line (at the end)

Hi, I have file as shown below. abc, def, abc, xyz, I have to remove ',' from end of last line (xyz,). How can I do that with single command? Is it possible or I have to iterate through complete file to remove that? - Malay (2 Replies)
Discussion started by: malaymaru
2 Replies

2. Shell Programming and Scripting

removing new line character

I'm appending header and trailer record for a binary file using echo "$header" > filename cat oldfilename >> filename echo "$trailer" >> filename The echo is introducing newline character after header and trailer.Please let me know is there any possibility to get rid of newline character. (2 Replies)
Discussion started by: ammu
2 Replies

3. UNIX for Dummies Questions & Answers

removing a character and addending to end in each line in a file

HI i am having a file this (sys19:pnlfct:/pfact/temp>) cat temp_sand 1234567890 1234567890 1234567890 1234567890 I want to make this file as (sys19:pnlfct:/pfact/temp>) cat temp_sand 1456789023 1456789023 1456789023 1456789023 just take the 2nd and 3rd position and put it... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies

4. Shell Programming and Scripting

How to concat line first and then removing the ^M character

hi Someone can give me some clue or script in writing the below requirement I am having 5 or 10 files of unix files which contain ^M charactes. First we have to find ^M character and concat the line where it has broken and then we have to remove the ^M character from the uxix... (11 Replies)
Discussion started by: vsantoshusa
11 Replies

5. Shell Programming and Scripting

Removing ^Z Character in a File

Hi, I am having a pipe (|) delimited file which is having ^Z character in the middle of the text.Could anyone please suggest me how to remove this ^Z Character from the file.I almost used all the ideas posted in this site but none of them worked in my case since tis ^Z character is not coming at... (4 Replies)
Discussion started by: phoenix86
4 Replies

6. Shell Programming and Scripting

Removing Special Character from File.

Hi, My file has this special character "^M" I would like to remove this characters. eg: abc,abc,^M i tried using sed but doesnt work. i used octal dump command to see special character it returns following: 015 \r Appreciate your reply. (6 Replies)
Discussion started by: pinnacle
6 Replies

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

8. UNIX for Dummies Questions & Answers

Need help removing last character of every line if certain character

I need help removing the last character of every line if it is a certain character. For example I need to get rid of a % character if it is in the last position. Input: aaa% %bbb ccc d%dd% Output should be: aaa %bbb ccc d%dd I tried this but it gets rid of all of the % characters.... (5 Replies)
Discussion started by: raptor25
5 Replies

9. Shell Programming and Scripting

Removing first and last character of line

Hi all, Please help me to remove first and last character of each line in a file. Thanks, Baski (5 Replies)
Discussion started by: baskivs
5 Replies

10. Shell Programming and Scripting

Removing last character of a specific line from a file

Hello guys, I would need to remove the last character ")" of a specific line. This can be from any line. Your help is appreciated. Below is the line. HOSTNAME=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)) Please help. (6 Replies)
Discussion started by: sang8g
6 Replies
tr(1B)						     SunOS/BSD Compatibility Package Commands						    tr(1B)

NAME
tr - translate characters SYNOPSIS
/usr/ucb/tr [-cds] [ string1 [string2]] DESCRIPTION
The tr utility copies the standard input to the standard output with substitution or deletion of selected characters. The arguments string1 and string2 are considered sets of characters. Any input character found in string1 is mapped into the character in the corresponding posi- tion within string2. When string2 is short, it is padded to the length of string1 by duplicating its last character. In either string the notation: a-b denotes a range of characters from a to b in increasing ASCII order. The character , followed by 1, 2 or 3 octal digits stands for the character whose ASCII code is given by those digits. As with the shell, the escape character , followed by any other character, escapes any special meaning for that character. OPTIONS
Any combination of the options -c, -d, or -s may be used: -c Complement the set of characters in string1 with respect to the universe of characters whose ASCII codes are 01 through 0377 octal. -d Delete all input characters in string1. -s Squeeze all strings of repeated output characters that are in string2 to single characters. EXAMPLES
Example 1: Creating a list of all the words in a filename The following example creates a list of all the words in filename1, one per line, in filename2, where a word is taken to be a maximal string of alphabetics. The second string is quoted to protect `' from the shell. 012 is the ASCII code for NEWLINE. example% tr -cs A-Za-z '12' <filename1>filename2 ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
ed(1), ascii(5), attributes(5) NOTES
Will not handle ASCII NUL in string1 or string2. tr always deletes NUL from input. SunOS 5.10 26 Sep 1992 tr(1B)
All times are GMT -4. The time now is 01:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy