Sponsored Content
Top Forums Shell Programming and Scripting Help with removal of spaces between operators and operands Post 302528385 by kumaran_5555 on Tuesday 7th of June 2011 04:42:28 AM
Old 06-07-2011
This is my try, in order to remove only spaces around operators, and braces, you may have to use sequence of seds

Code:
 sed -e 's/ (/(/g' -e 's/) /)/g' -e 's/ =/=/g' -e 's/= /=/g' -e  's/ +/+/g'   -e  's/+ /+/g' test_file

you can add few other operators like *,-
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Arithmetic Operators

Hello, I have a list of 'inputs' and i want to convert those on the second list named 'Desired Outputs', but i don't know how to do it? Inputs Desired Outputs 1 2 94 4 276 8 369 10 464 12 ... (0 Replies)
Discussion started by: filda
0 Replies

2. UNIX for Dummies Questions & Answers

Operators

I am trying to understand Does the following: {tmp+=$10} Mean take $10 and add them all up and call it tmp thanks! (2 Replies)
Discussion started by: llsmr777
2 Replies

3. UNIX for Dummies Questions & Answers

selective removal of blank spaces in string

Hi, I'm a newbie to shell scripting and I have the following problem: I need all spaces between two letters or a letter and a number exchanged for an underscore, but all spaces between a letter and other characters need to remain. Searching forums didn't help... One example for clarity: ... (3 Replies)
Discussion started by: Cpt_Cell
3 Replies

4. Shell Programming and Scripting

Operators

I really don't know the meaning of these operators. Could someone explain the meanings so I can make my test for today? <, <=, ==, !=, >=, >, ||, &&, ! ~ , !~ Thanks! (1 Reply)
Discussion started by: Erjen
1 Replies

5. Homework & Coursework Questions

Operators

I really don't know the meaning of these operators. Could someone explain the meanings? <, <=, ==, !=, >=, >, ||, &&, ! ~ , !~ Thanks! (1 Reply)
Discussion started by: Erjen
1 Replies

6. Shell Programming and Scripting

Help with removal of blank spaces in a file

Hello.. I have a text file. I want to remove all the blank spaces(except tab) from the file.. I tried using sed command as shown below sed 's/ //g' file1 But the problem with the above command is that it also eliminates 'tab' which is between the columns.. For example if the contents... (7 Replies)
Discussion started by: abk07
7 Replies

7. Shell Programming and Scripting

Help with removal of blank spaces from the second field!

Hi everyone.. I'm trying to eliminate multiple whitespaces from a file.. I must make use of shell script to eliminate whitespaces.. Take a look at the sample file 1 int main() 2 { 3 int a,b; 4 printf("Enter the values of a and b"); 5 scanf("%d%d",&a,&b); 6 if(a>b) ... (6 Replies)
Discussion started by: abk07
6 Replies

8. Shell Programming and Scripting

Array operators

Hi Lets say I have two arrays: VAR_1 = "File_A" "File_B" "File_C" "File_D" VAR_2 = "File_A" "File_D" Is there a simple command to get the difference of these list, i.e. VAR_1_2 = "File_B" "File_C" or do I have to write a script and loop through all elements and compare them one by one? ... (1 Reply)
Discussion started by: Wernfried
1 Replies

9. Shell Programming and Scripting

Removal of extra spaces in *.log files to allow extraction of frequencies

Our university has upgraded its version of a computational chemistry program that our group uses quite regularly. In the past we have been able to extract frequency spectra from log files that are generated. Since the upgrade, the viewing program errors out. I've been able to trace down the changes... (16 Replies)
Discussion started by: wsuchem
16 Replies
integer(3pm)						 Perl Programmers Reference Guide					      integer(3pm)

NAME
integer - Perl pragma to use integer arithmetic instead of floating point SYNOPSIS
use integer; $x = 10/3; # $x is now 3, not 3.33333333333333333 DESCRIPTION
This tells the compiler to use integer operations from here to the end of the enclosing BLOCK. On many machines, this doesn't matter a great deal for most computations, but on those without floating point hardware, it can make a big difference in performance. Note that this only affects how most of the arithmetic and relational operators handle their operands and results, and not how all numbers everywhere are treated. Specifically, "use integer;" has the effect that before computing the results of the arithmetic operators (+, -, *, /, %, +=, -=, *=, /=, %=, and unary minus), the comparison operators (<, <=, >, >=, ==, !=, <=>), and the bitwise operators (|, &, ^, <<, >>, |=, &=, ^=, <<=, >>=), the operands have their fractional portions truncated (or floored), and the result will have its fractional portion truncated as well. In addition, the range of operands and results is restricted to that of familiar two's complement integers, i.e., -(2**31) .. (2**31-1) on 32-bit architectures, and -(2**63) .. (2**63-1) on 64-bit architectures. For example, this code use integer; $x = 5.8; $y = 2.5; $z = 2.7; $a = 2**31 - 1; # Largest positive integer on 32-bit machines $, = ", "; print $x, -$x, $x + $y, $x - $y, $x / $y, $x * $y, $y == $z, $a, $a + 1; will print: 5.8, -5, 7, 3, 2, 10, 1, 2147483647, -2147483648 Note that $x is still printed as having its true non-integer value of 5.8 since it wasn't operated on. And note too the wrap-around from the largest positive integer to the largest negative one. Also, arguments passed to functions and the values returned by them are not affected by "use integer;". E.g., srand(1.5); $, = ", "; print sin(.5), cos(.5), atan2(1,2), sqrt(2), rand(10); will give the same result with or without "use integer;" The power operator "**" is also not affected, so that 2 ** .5 is always the square root of 2. Now, it so happens that the pre- and post- increment and decrement operators, ++ and --, are not affected by "use integer;" either. Some may rightly consider this to be a bug -- but at least it's a long-standing one. Finally, "use integer;" also has an additional affect on the bitwise operators. Normally, the operands and results are treated as unsigned integers, but with "use integer;" the operands and results are signed. This means, among other things, that ~0 is -1, and -2 & -5 is -6. Internally, native integer arithmetic (as provided by your C compiler) is used. This means that Perl's own semantics for arithmetic operations may not be preserved. One common source of trouble is the modulus of negative numbers, which Perl does one way, but your hardware may do another. % perl -le 'print (4 % -3)' -2 % perl -Minteger -le 'print (4 % -3)' 1 See "Pragmatic Modules" in perlmodlib, "Integer Arithmetic" in perlop perl v5.12.1 2010-04-26 integer(3pm)
All times are GMT -4. The time now is 11:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy