Sponsored Content
Top Forums Shell Programming and Scripting replacing numbers greater than 0 with 1 Post 302202126 by vgersh99 on Wednesday 4th of June 2008 06:52:21 AM
Old 06-04-2008
Quote:
Originally Posted by vrms
I have some ASCII files containing numerous numbers. What I'd like to do is replace all numbers greater than 0 with 1.

Examples of the numbers include: - 000011 and 000042

Thanks
Pls show a sample file and a desired output.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to perform calculations using numbers greater than 2150000000.

Could someone tell me how to perform calculations using numbers greater than 2150000000 in Korn Shell? When I tried to do it it gave me the wrong answer. e.g. I have a ksh file with the contents below: --------------------------------- #!/bin/ksh SUM=`expr 2150000000 + 2` PRODUCT=`expr... (3 Replies)
Discussion started by: stevefox
3 Replies

2. Shell Programming and Scripting

Need help in finding and replacing port numbers.

Hi All, I am trying to write a shell script which firstly will search some files and then increase the port numbers mentioned in them by a certain no. let me clear it with an example- suppose there r few files a,b,c,d.... file a's content- <serverEntries xmi:id="ServerEntry_1"... (3 Replies)
Discussion started by: ankushsingh10
3 Replies

3. Shell Programming and Scripting

Replacing numbers in bash scripts

Hi, I have lines in some files that look exactly as below, and the line numbers they occur in are always the same. (Lines 136-139) W 0.00000000 0.00000000 2.00000000 W 0.50000000 0.50000000 2.50000000 W 0.00000000 0.00000000 3.00000000 W 0.50000000 0.50000000 3.50000000 I'd like to... (0 Replies)
Discussion started by: bluesmodular
0 Replies

4. Shell Programming and Scripting

Preserving Empty Lines while Replacing Numbers

Greetings, I am using tcsh to write a script that will replace the numbers in a file with a single number, the caveat is that this file has blank lines which are necessary for another step down the line so I need to preserve the blank lines. I have tried sed and awk but both will collapse the... (1 Reply)
Discussion started by: bonesy
1 Replies

5. UNIX for Dummies Questions & Answers

need a command to search for numbers greater than 3000

i have a file contains: 13213,A,300 3423,C,200 5563,A,201 3000,A,400 3000,A,402 3000,A,206 3000,A,303 3000,A,200 4233,N,204 i need to search for numbers in the first column are greater than 3000? i have another issue if you can help me? if i want to search in the second or the... (7 Replies)
Discussion started by: takyeldin
7 Replies

6. Shell Programming and Scripting

Mapping and replacing numbers in two files

hi i have two files one of the form 1 2 2 45 3 56 4 98 5 6598 6 98 7 10 8 0 9 15 10 56 This file's significance is that it maps the number in first column to that of the number in second column The other file is of the form 1 2 (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

7. Shell Programming and Scripting

How to search for numbers greater than x?

I have a file with multiple fields, example below File 1: Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|100 Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|101 Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|102 Field 1|Field 2|Field 3|Field 4|Field 5|Field... (4 Replies)
Discussion started by: castrojc
4 Replies

8. UNIX for Dummies Questions & Answers

Grep lines with numbers greater than 2 digits at the end of the line

I'm trying to grep lines where the digits at the end of each line are greater than digits. Tried this but it will only allow me to specify 2 digits. Any ideas would greatly be appreciated. grep -i '\<\{3,4,5\}\>' file ---------- Post updated at 05:58 PM ---------- Previous update was at 05:41... (1 Reply)
Discussion started by: jimmyf
1 Replies

9. Shell Programming and Scripting

Replacing a character between two numbers

Hi, I need to replace a character between two numbers (specifically a - to a _). The problem is that they can be *any* numbers. So, I need a one liner to turn a file like this: 1-2 3-4 55-66 4323-12312893 into the following 1_2 3_4 55_66 4323_12312893 Any help would be appreciated! (5 Replies)
Discussion started by: mikey11415
5 Replies

10. UNIX for Advanced & Expert Users

Search for columns with numbers greater than 70

This helped get me started. https://www.unix.com/unix-for-dummies-questions-and-answers/157026-need-command-search-numbers-greater-than-3000-a.html This is the command I am using. I am trying to find numbers greater than 70 in column 5. I do not know if it is getting confused because there... (6 Replies)
Discussion started by: cokedude
6 Replies
VRMS(1) 						      General Commands Manual							   VRMS(1)

NAME
vrms - report of installed non-free software SYNOPSIS
vrms [OPTION] ... DESCRIPTION
This program began as an attempt to create a "virtual Richard M. Stallman" for Debian GNU/Linux. Thus the choice of name. This program analyzes the currently-installed package list on a Debian GNU/Linux system, and reports the non-free and contrib packages that are currently installed to stdout. In some cases, such as regarding documentation licensed under the GNU Free Documentation License with invariant sections, the opinions of Richard M. Stallman and the Debian project have diverged since this program was originally written. In such cases, this program follows the definition of freedom embodied in the Debian Free Software Guidelines. The packages in the non-free tree have restrictions on their use and/or distribution which cause them to fail to meet the terms of the Debian Free Software Guidelines included as part of the Debian Social Contract. However, some are sufficiently useful that their presence is often tolerated by Debian users despite their licensing. The packages in the contrib tree are themselves free software but have some dependency on non-free software for their use that make them worthy of reporting so that their use can also be consciously considered. Richard is the most vocal among us on the issue of software morality, and we agree with Richard that Debian users should have an easy way to know when they are running non-free software on their systems. This program is our attempt to fill that need. OPTIONS
All options can be prefixed with -- (eg: --noexplain) to turn them off. -q, --quiet Do nothing if there are no non-free packages installed. -e, --explain Give a brief explanation of why each package is non-free, if available. This is the default. -s, --sparse Just output a list of non-free packages. --reason-dir=DIR Use DIR as the reason directory, instead of /usr/share/vrms/reasons/. -h, --help Display help. -d, --debug Generate debugging information. FILES
/usr/share/vrms/reasons Default source of explanations for why packages are non-free. HISTORY
This program was written by Bdale Garbee and Bill Geddes for the Debian GNU/Linux system, in response to an open discussion with Richard Stallman about the issues surrounding the availability/desirability of the 'non-free' package tree in Debian. A Cute Little Hack VRMS(1)
All times are GMT -4. The time now is 12:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy