Sponsored Content
Top Forums Shell Programming and Scripting Clearing leading and trailing blanks from a string in C Shell Post 302633317 by phudgens on Tuesday 1st of May 2012 05:11:52 PM
Old 05-01-2012
Clearing leading and trailing blanks from a string in C Shell

Does anyone know of a way with C Shell that will work on both Linux and Sun to clear all leading and trailing blanks from a previously specified string? I am using the following code to replace blanks with underscores:
Code:
set Company = `echo $Company | sed 's/ /_/g

but I don't want any leading or trailing underscores. The string was originally defined using:
Code:
set COMPLine = `grep  -i "COMPANY" $LASInputFile`
set Company = `echo $COMPLine | sed 's/^[^ ][^ ]* *\([^:][^:]*\)[ ][ ]*:.*/\1/'`

Thanks for any help
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Leading and Trailing Spaces

Hi, how to i remove leading and trailing spaces from a line? the spaces can be behind or in front of any field or line example of a line in the input data: Amy Reds , 100 , /bin/sh how to i get it to be: Amy Read,100,/bin/sh i saw something on this on the Man pages for AWK... (7 Replies)
Discussion started by: sleepster
7 Replies

2. UNIX for Advanced & Expert Users

FTP Between UNIX & Windows drops leading blanks

I am using ftp on Solaris to transfer files to Windows 2000 that have leading blanks in the name (ex. " 12345A4444.BIN"). When they get to Windows the leading blanks are stripped off. Has anyone encountered this and is there a fix? If I use Hummingbird it is ok but that is not an option for... (6 Replies)
Discussion started by: worf52
6 Replies

3. Shell Programming and Scripting

Strip leading and trailing spaces only in a shell variable with embedded spaces

I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help. echo $SH_VAR | command_line Syntax. The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies

4. Shell Programming and Scripting

how to remove trailing blanks, tabs

Hi I need to delete trailing spaces, tabs and unprintable charactes from the file. This file has a number of blank lines which should be left intact. Another words I am trying to remove the junk at the end of each line. Does anyone come across the similar problem? Thanks a lot for any help -A (3 Replies)
Discussion started by: aoussenko
3 Replies

5. Shell Programming and Scripting

remove trailing and leading spaces using tr command

Dear All, can you please advice how do i remove trailing and leading spaces from a pipe-delimited file using "tr" command the below cmd, i tried removed all spaces tr -d ' '<s1.txt>s2.txt1 Many thx Suresh (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

6. Shell Programming and Scripting

Removing leading and trailing spaces only in PERL

Hi All, I have a file with the following contents with multiple lines 172445957| 000005911|8| 400 Peninsula Ave.#1551 | And,K |935172445957|000005911 607573888 |000098536 | 2|Ane, B |J |Ane |1868 |19861206|20090106|20071001 I want to trim the "leading and trailing spaces only" from... (2 Replies)
Discussion started by: kumar04
2 Replies

7. Shell Programming and Scripting

Help to move leading negative sign to trailing position

Hi All, I am having a file which contains negative numbers, wht i am doing is re-formattting the file(moving few columns and add few hard codings between), while reformatting i would want the negative numbers to have the sign as trailing rather than leading. Existing -2400.00 34 0.00... (11 Replies)
Discussion started by: selvankj
11 Replies

8. Shell Programming and Scripting

Leading blanks

Hi Ich have a list as follows 73 5 100 45 81 4 and I would like to have an output (on screen) like that 73 5 100 45 81 4 (6 Replies)
Discussion started by: lazybaer
6 Replies

9. Shell Programming and Scripting

Remove leading and trailing spaces from a file

Hi, I am trying to remove leading and trailing spaces from a file using awk but somehow I have not been able to do it. Here is the data that I want to trim. 07/12/2017 15:55:00 |entinfdev |AD ping Time ms | .474| 1.41| .581|green |flat... (9 Replies)
Discussion started by: svajhala
9 Replies

10. Shell Programming and Scripting

How to remove leading and trailing spaces for variable in shell script?

Hi I have variable named tablename. The value to tablename variable has leading and trailing white spaces. How to remove the leading and training white spaces and write the value of the tablename without space to a file using shell script. ( for e.g. tablename= yyy ) INPUT ... (10 Replies)
Discussion started by: pottic
10 Replies
LDAP_COMPARE(3) 							 1							   LDAP_COMPARE(3)

ldap_compare - Compare value of attribute found in entry specified with DN

SYNOPSIS
mixed ldap_compare (resource $link_identifier, string $dn, string $attribute, string $value) DESCRIPTION
Compare $value of $attribute with value of same attribute in an LDAP directory entry. PARAMETERS
o $link_identifier - An LDAP link identifier, returned by ldap_connect(3). o $dn - The distinguished name of an LDAP entity. o $attribute - The attribute name. o $value - The compared value. RETURN VALUES
Returns TRUE if $value matches otherwise returns FALSE. Returns -1 on error. EXAMPLES
The following example demonstrates how to check whether or not given password matches the one defined in DN specified entry. Example #1 Complete example of password check <?php $ds=ldap_connect("localhost"); // assuming the LDAP server is on this host if ($ds) { // bind if (ldap_bind($ds)) { // prepare data $dn = "cn=Matti Meikku, ou=My Unit, o=My Company, c=FI"; $value = "secretpassword"; $attr = "password"; // compare value $r=ldap_compare($ds, $dn, $attr, $value); if ($r === -1) { echo "Error: " . ldap_error($ds); } elseif ($r === true) { echo "Password correct."; } elseif ($r === false) { echo "Wrong guess! Password incorrect."; } } else { echo "Unable to bind to LDAP server."; } ldap_close($ds); } else { echo "Unable to connect to LDAP server."; } ?> NOTES
Warning ldap_compare(3) can NOT be used to compare BINARY values! PHP Documentation Group LDAP_COMPARE(3)
All times are GMT -4. The time now is 07:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy