Sponsored Content
Full Discussion: Remove trailing space
Top Forums Shell Programming and Scripting Remove trailing space Post 302829155 by munna_dude on Thursday 4th of July 2013 05:54:53 AM
Old 07-04-2013
Quote:
Originally Posted by Don Cragun
The backslash won't matter. ${value%% }, ${value%%\ }, ${value% }, and ${value%\ } all expand to the value of the variable value with a single trailing space removed (if there was one) when using any shell that performs shell variable expansions as specified by the POSIX standards and the Single UNIX Specifications. (The Bourne shell and shells derived from csh do not recognize this syntax.)
Hi,

Thanks for the quick reply.

When I try to put it in "eval" command it is not accepting.
Is there any way to use/avoid trailing space here.

Code:
eval $value=\"${arr["$value"]}\"

present output is "tmp= lib" (please observe there is a space after =)

expected output is "tmp=lib" (without trailing space)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

re: removing trailing space from lines

Not sure why this thread was closed without any explanation, but you can do what you're asking with sed 's/]*$//g' < sourceFile > destFile (1 Reply)
Discussion started by: oombera
1 Replies

2. UNIX for Dummies Questions & Answers

How to remove trailing spaces

Hi, I have a file like this (ADD_MONTHS((Substr(Trim(BOTH FROM Translate(Maximum(closeDa ------------------------------------------------------------ 2007-06-30 00:00:00 I have a requirement where i need just the date. When i do: tail -1... (2 Replies)
Discussion started by: mahek_bedi
2 Replies

3. Shell Programming and Scripting

Remove trailing G

Hello, I am trying to write a script that will calculate the amount of data remaining in a storage volume. I'm running Tru64 Unix version 5.1B patch kit 6. The script is being run against an AdvFS domain. I am programming in Korn Shell version M-11/16/88f. The basic idea is that I want to run df... (3 Replies)
Discussion started by: Heathe_Kyle
3 Replies

4. Shell Programming and Scripting

Delete trailing white space

I have a string "disk0 with a trailing white space after it" but I want to get rid of this white space from right to left so that I am left with "disk0" only. Using sed 's/ $//g' doesn't seem to work Any ideas ? Thanks (5 Replies)
Discussion started by: cillmor
5 Replies

5. Shell Programming and Scripting

Remove trailing zeros

Hi I have a simple request but can't find the answer. I want to remove trailing zeros, and in some cases the fullstops, from the input data. Example of input file: FR002_15.000_20.000 SD475_5.000_10.500 FG5647_12.250_15.500 BH2463_30.555_32.000 Desired output file would be: ... (10 Replies)
Discussion started by: theflamingmoe
10 Replies

6. Shell Programming and Scripting

Remove trailing 0 from the field

Hi Freinds, I have file1.txt as below file1.txt 1521894~~-0.400~201207 1521794~~-0.486~201207 152494~~-0.490~201207 152154894~~-0.490~201207 1521894354~~-0.489~201207 expected output : 1521894~~-0.4~201207 1521794~~-0.486~201207 152494~~-0.49~201207... (9 Replies)
Discussion started by: i150371485
9 Replies

7. Shell Programming and Scripting

Replacing trailing space with single quote

Platform : RHEL 5.8 I want to end each line of this file with a single quote. $ cat hello.txt blueskies minnie mickey gravity snoopyAt VI editor's command mode, I have used the following command to replace the last character with a single quote. ~ ~ ~ :%s/$/'/gNow, the lines in the... (10 Replies)
Discussion started by: John K
10 Replies

8. Shell Programming and Scripting

Remove trailing number

I have some strings such as ABC1 ABC2 TYFASDD12 They will only have letters and numbers. In each case I want to remove the last digit? The lengths will vary. So a hard coded substr won't work. What do I do? if it doesn't end in a number, I don't want to remove any characters. (6 Replies)
Discussion started by: guessingo
6 Replies

9. Shell Programming and Scripting

Remove trailing space from file and folder names

I have a folder that contains many sub folders and files. This tree has to be backed up to an archive system. According to the tech support, one of the archives is failing to back up due to the possibility of trailing spaces on file and folder names. Therefore, I would like to have a script... (16 Replies)
Discussion started by: vipertech
16 Replies

10. Shell Programming and Scripting

Remove trailing space in Gawk

Hi, I have simply made a shell script to convert *.csv to *.xml file. Xml file is required for input to one tool. But i am getting space after last field. How can i remove it. Shell script is as follows :- if then echo "" echo "Wrong syntax, Databse_update.sh... (6 Replies)
Discussion started by: stillrules
6 Replies
resize(1X)																resize(1X)

NAME
resize - set TERMCAP and terminal settings to current xterm window size SYNOPSIS
resize [-u] [-c] [-s[row col]] OPTIONS
The following options may be used with resize: This option indicates that Bourne shell commands should be generated even if the user's cur- rent shell is not /bin/sh. This option indicates that C shell commands should be generated even if the user's current shell is not /bin/csh. This option indicates that Sun console escape sequences will be used instead of the special xterm escape code. If rows and col- umns are given, resize will ask the xterm to resize itself. However, the window manager may choose to disallow the change. DESCRIPTION
The resize command prints a shell command for setting the TERM and TERMCAP environment variables to indicate the current size of xterm win- dow from which the command is run. For this output to take effect, resize must either be evaluated as part of the command line (usually done with a shell alias or function) or else redirected to a file which can then be read in. From the C shell (usually known as /bin/csh), the following alias could be defined in the user's % alias rs 'set noglob; eval `resize`' After resizing the window, the user would type: % rs Users of versions of the Bourne shell (usually known as /bin/sh) that do not have command functions will need to send the output to a tem- porary file and the read it back in with the "." command: $ resize > /tmp/out $ . /tmp/out FILES
for the base termcap entry to modify. user's alias for the command. BUGS
The -u or -c must appear to the left of -s if both are specified. SEE ALSO
csh(1), tset(1), xterm(1X) AUTHORS
Mark Vandevoorde (MIT-Athena), Edward Moy (Berkeley) Copyright (c) 1984, 1985 by X Consortium See X(1X) for a complete copyright notice. resize(1X)
All times are GMT -4. The time now is 03:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy