Sponsored Content
Top Forums Shell Programming and Scripting Help to move leading negative sign to trailing position Post 302537098 by selvankj on Thursday 7th of July 2011 05:20:19 AM
Old 07-07-2011
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
Code:
-2400.00
34
0.00
-987.00
-92.56

Required
Code:
2400.00-
34
0.00
987.00-
92.56-

FYI am using awk on every line to reformat the line to create a new format
Code:
cat $FILENAME |grep ^3 | while read line
do
  echo "$line" | nawk ' BEGIN {FS=","}  {print("5",$1,$28,"$27",$26)}' >> New_file
done


Last edited by Franklin52; 07-07-2011 at 06:50 AM.. Reason: Please use code tags for code and data samples, thank you
 

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 Dummies Questions & Answers

Removing leading and trailing spaces of data between the tags in xml.

I am having xml document as below. <transactionid> 00 </transactionid> <tracknumber> 0 </tracknumber> <key> N/A </key> But the data contains leading and trailing spaces between the tags. Please let me know how can i remove these leading and trailing spaces between the tags.... (2 Replies)
Discussion started by: jhmr7
2 Replies

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

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

5. Shell Programming and Scripting

Finding the most positive and negative value and defining its position

Hi, I have a file that looks like this: Jake 2 3 4 6 4 3 -2 -1 Jerry 1 2 3 2 1 7 -6 -1 Timmy -1 -4 -5 -8 9 3 1 I want to find the most positive and negative value for each row and also define its position (based on column #) So the output would look... (7 Replies)
Discussion started by: gisele_l
7 Replies

6. Shell Programming and Scripting

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: set Company = `echo $Company | sed 's/ /_/g but I don't want any... (1 Reply)
Discussion started by: phudgens
1 Replies

7. Shell Programming and Scripting

In a row, replace negative sign and find minimum value among four columns

Hi Friends, I have an input file like this chr1 100 200 1 2 3 4 chr1 150 200 4 5 6 7 chr2 300 400 9 6 7 1 chr2 300 410 -10 21 -11 13 chr3 700 900 -21 -22 130 165 Now, my output file is chr1 100 200 1 chr1 150 200 4 chr2 300 400 1 chr2 300 410 10 chr3 700 900 21 Remove... (5 Replies)
Discussion started by: jacobs.smith
5 Replies

8. Shell Programming and Scripting

Remove the leading and trailing date from a CSV file

I'm a newbie to shell scripting. Can anyone help with the below requirement ? The leading and trailing date of a files to be removed. 2017-07-12_gmr_tag_log_20170711.csv 2017-07-12_gmr_call_log_20170711.csv 2017-07-12_gmr_outgoing_log_20170711.csv I'm looking for output like... (7 Replies)
Discussion started by: shivamayam
7 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
DVISELECT(1)						      General Commands Manual						      DVISELECT(1)

NAME
dviselect - extract pages from DVI files SYNOPSIS
dviselect [ -s ] [ -i infile ] [ -o outfile ] list of pages [ infile [ outfile ] ] DESCRIPTION
Dviselect selects pages from a DVI file produced by TeX, creating a new DVI file usable by any of the TeX conversion programs, or even by dviselect itself. A range is a string of the form even, odd, or first:last where both first and last are optional numeric strings, with negative numbers indicated by a leading underscore character ``_''. If both first and last are omitted, the colon may also be omitted, or may be replaced with an asterisk ``*''. A page range is a list of ranges separated by periods. A list of pages is described by a set of page ranges sepa- rated by commas and/or white space. Dviselect actually looks at the ten count variables that TeX writes; the first of these (count0) is the page number, with count1 through count9 having varied uses depending on which macro packages are in use. (Typically count1 might be a chapter or section number.) A page is included in dviselect's output if all its count values match any one of the ranges listed on the command line. For example, the com- mand ``dviselect *.1,35:'' might select everything in chapter 1, as well as pages 35 and up. ``dviselect 10:30'' would select pages 10 through 30 (inclusive). ``:43'' means everything up to and including page 43 (including negative-numbered pages). To get all even-num- bered pages, use ``even''; to get all odd-numbered pages, use ``odd''. If a Table of Contents has negative page numbers, ``:_1'' will select it. Note that ``*'' must be quoted from the shell; the empty string is more convenient to use, if harder to read. Instead of count values, dviselect can also select by ``absolute page number'', where the first page is page 1, the second page 2, and so forth. Absolute page numbers are indicated by a leading equal sign ``=''. Ranges of absolute pages are also allowed: ``dviselect =3:7'' will extract the third through seventh pages. Dot separators are not legal in absolute ranges, and there are no negative absolute page numbers. Even/odd specifiers, however, are legal; ``dviselect =even'' selects every other page, starting with the second. More precisely, an asterisk or an empty string implies no limit; an equal sign means absolute page number rather than counts; a leading colon means everything up to and including the given page; a trailing colon means everything from the given page on; the word ``even'' means only even values shall be accepted; the word ``odd'' means only odd values shall be accepted; and a period indicates that the next count should be examined. If fewer than 10 ranges are specified, the remaining counts are left unrestricted (that is, ``1:5'' and ``1:5.*'' are equivalent). A single number n is treated as if it were the range n:n. An arbitrary number of page selectors may be given, separated by commas or whitespace; a page is selected if any of the selectors matches its counts or absolute page number. Dviselect normally prints the page numbers of the pages selected; the -s option suppresses this. AUTHOR
Chris Torek, University of Maryland SEE ALSO
dviconcat(1), latex(1), tex(1) MC-TeX User's Guide The TeXbook BUGS
A leading ``-'' ought to be allowed for negative numbers, but it is currently used as a synonym for ``:'', for backwards compatibility. Section or subsection selection will sometimes fail, for the DVI file lists only the count values that were active when the page ended. Clever macro packages can alleviate this by making use of other ``free'' count registers. Chapters normally begin on new pages, and do not suffer from this particular problem. The heuristic that decides which arguments are page selectors and which are file names is often wrong. Using shell redirection or the -i and -o options is safest. Dviselect does not adjust the parameters in the postamble; however, since these values are normally used only to size certain structures in the output conversion programs, and the parameters never need to be adjusted upward, this has not proven to be a problem. DVISELECT(1)
All times are GMT -4. The time now is 01:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy