Sponsored Content
Full Discussion: deleting white spaces
Top Forums UNIX for Dummies Questions & Answers deleting white spaces Post 47552 by cary530 on Thursday 12th of February 2004 10:33:53 AM
Old 02-12-2004
Oh, i'm sorry, you know what the unique expressions are.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

delete white spaces

hi all... i have the next question: i have a flat file with a lot of records (lines). Each record has 10 fields, which are separated by pipe (|). My problem is what sometimes, in the first record, there are white spaces (no values, nothing) in the beginning of the record, like this: ws ws... (2 Replies)
Discussion started by: DebianJ
2 Replies

2. Shell Programming and Scripting

trimming white spaces

I have a variable that calls in a string from txt file. Problem is the string comes with an abundance of white spaces trailing it. Is there any easy way to trim the tailing white spaces off at the end? Thanks in advance. (9 Replies)
Discussion started by: briskbaby
9 Replies

3. Shell Programming and Scripting

Two or more white spaces in string

Hi, Can anybody suggest me how to combine two strings with two or more white spaces and assign it to a variable? E.g. first=HAI second=HELLO third="$first $second" # appending strings with more than one white spaces echo $third this would print HAI HELLO Output appears... (2 Replies)
Discussion started by: harish_oty
2 Replies

4. UNIX for Dummies Questions & Answers

Delete Multiple White Spaces

Hi, I have a file that has multiple spaces between characters. I want to delete or convert the multiple spaces into a single space. I think this can be done in "sed" but I only know the syntax to delete trailing or leading spaces. Can this be done with "sed" or awk? I have a file that looks... (6 Replies)
Discussion started by: eja
6 Replies

5. UNIX for Dummies Questions & Answers

deleting white spaces in a file

Hello Guys, I am a newbie to unix. I am having a requirement. Please help me for finding a solution for this, I am having a file as mentioned below: $ cat shank ackca acackac akcajc akcjkcja akcj ckcklc I want to delete all the white spaces in this file, I tried... (2 Replies)
Discussion started by: mraghunandanan
2 Replies

6. Shell Programming and Scripting

white spaces in bash autocompletion

Hello dear community! I've recently written a BASH function for auto completion of options. It works like following: if a user types a command and then an argument to this command which starts with "^-" and then presses TAB, then 'user_command --help (or -h)' is invoked and possible options are... (0 Replies)
Discussion started by: sidorenko
0 Replies

7. UNIX for Dummies Questions & Answers

Problem with White spaces and tabs

Hi All, I am facing issues converting white spaces and tabs together in a file I am reading. Here is the command I am trying: tr -s ' '@ | sort -t@ +1n filename I guess the problem is that it is not converting the tabs to another delimiter. Also, I am supposed to accomplish this only using... (5 Replies)
Discussion started by: sh_kk
5 Replies

8. Shell Programming and Scripting

Leading white spaces

Hi, I am having problem in deleting the leading spaces:- cat x.csv baseball,NULL,8798765,Most played baseball,NULL,8928192,Most played baseball,NULL,5678945,Most played cricket,NOTNULL,125782,Usually played cricket,NOTNULL,678921,Usually played $ nawk 'BEGIN{FS=","}!a... (2 Replies)
Discussion started by: scripter12
2 Replies

9. Shell Programming and Scripting

Replacing white spaces in filename

Hi; In following code find LOG_DIR -type f | while read filename; do echo $filename; done I want to precede each white space encountered in filename with \ so that when i use $filename for running some commands in do...done,it wont give me an error. will appreciate ur help in this.... (1 Reply)
Discussion started by: ajaypadvi
1 Replies

10. Shell Programming and Scripting

Bash - read white spaces

Hello! I have one problem with my bash script - I would like to be able to read white space characters from stdin (for example single " ") - can I acomplish that somehow? I need to read only one character at the time, so I use read -s -n 1 var but it doesn't work for whitespaces apparently. ... (3 Replies)
Discussion started by: xqwzts
3 Replies
expr(1) 						      General Commands Manual							   expr(1)

NAME
expr - Evaluates arguments as expressions SYNOPSIS
expr expression STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: expr: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
None OPERANDS
The single expression evaluated by expr will be formed from the operands, as described in the DESCRIPTION section. Each of the expression operator symbols: ( ) | & = > >= < <= != + - * / % : and the symbols integer and string in the DESCRIPTION sec- tion must be provided as separate arguments to expr. Expression to be evaluated, formed as explained in the DESCRIPTION section. DESCRIPTION
The expr command reads an expression, evaluates it, and writes the result to standard output. Within the expression argument, you must separate each term with spaces, precede characters special to the shell with a (backslash), and quote strings containing spaces or other special characters. Note that expr returns 0 to indicate a zero value, rather than the null string. Integers can be preceded by a unary minus sign. Internally, integers are treated as 64-bit or 32-bit two's complement numbers, depending on the word size of the hardware platform. The operators and keywords are described in the following listing. Characters that need to be escaped are preceded by a (backslash). The list is in order of increasing precedence with equal precedence operators grouped within {} (braces). Returns expression1 if it is neither null nor 0 (zero); otherwise, returns expression2. Returns expression1 if neither expression1 nor expression2 is null nor 0; oth- erwise, returns 0. Returns the result of an integer comparison if both expressions are integers; otherwise, returns the result of a string comparison. Adds or subtracts integer-valued arguments. Multiplies, divides, or provides the remainder from the division of integer-val- ued arguments. Compares expression1 with expression2, which must be a basic regular expression, with syntax as described for grep, except that all patterns are anchored, so ^ (circumflex) (which anchors a pattern to the beginning of a line) is not a special character in this context. Normally, the matching operator returns the number of characters matched. Alternatively, you can use the (...) symbols in expres- sion2 to return a portion of expression1. Provides expression grouping. An argument consisting only of an (optional) unary minus followed by digits. A string argument. Refer to the STRING OPERAND section. To avoid unpredictable results when using a range expression to match a class of characters, use a character class expression rather than a standard range expression. For information about character class expressions, see the discussion of this topic included in the description of the grep command. FUNCTIONS [Tru64 UNIX] The expr command provides the following string-expression functions. Strings containing white space must be quoted. A string argument should not be one of the expression operator symbols shown in the OPERANDS section or one of the string function names below. You cannot use, for example, match "$subject" "$pattern" unless it is confirmed that subject and pattern do not match this viola- tion. The first character of a string is position 1. The information returned by all these functions is in the form of a string: [Tru64 UNIX] Compares each character in the second string against each character in the first string and returns the position in the first string of the first match found, where the first match is the match closest to the beginning of string1. [Tru64 UNIX] Returns the length of the string argument. [Tru64 UNIX] See the description of the : (colon) match operator, above. [Tru64 UNIX] Returns the substring of string that begins at character position start and is length characters long. STRING OPERAND A string argument is an argument that cannot be identified as an integer argument or as one of the expression operator symbols shown in the OPERANDS section. The use of string arguments length, substr, index or match produces unspecified results. EXIT STATUS
The expr command returns the following exit values: The expression is neither null nor 0. The expression is null or 0. The expression is invalid. An error occurred. EXAMPLES
To increment a shell variable, enter: COUNT=`expr $COUNT + 1` This adds 1 to the COUNT shell variable (see sh for details). To find the length of a shell variable, enter: RES=`expr "$VAR" : ".*"` Note that VAR is in double quotes to avoid problems where VAR is NULL or contains embedded spaces. The regular expression is also quoted to avoid expansion by the shell. This operation can also be performed as: RES=`expr length "$VAR"` To use part of a shell variable, enter: RES=`expr "$VAR" : "-*(.*)"` This removes leading - (dashes), if any, from VAR. If the ( ) characters were omitted, RES would contain the length of VAR. To find a character from one string in another string, enter: INDEX=`expr index "Hello World!" "Wo"` Note that the returned value is 5, not 7. The first match is the fifth character in string1, matching the o in string2 rather than the W, which is the seventh character in string1. Special considerations: RES=`expr "x$VAR" : "x-*(.*)"` This succeeds even if VAR has the value - (dash). RES=`expr "x$VAR" = "x=" This succeeds even if VAR has the value = (equal sign). ENVIRONMENT VARIABLES
The following environment variables affect the execution of expr: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments) and the behavior of character classes in regular expressions.. Determines the locale for the format and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: grep(1), Bourne shell sh(1b), POSIX shell sh(1p), test(1) Functions: string(3), wcscat(3) Standards: standards(5) expr(1)
All times are GMT -4. The time now is 06:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy