Sponsored Content
Top Forums Shell Programming and Scripting changing number in bash (number is in form of string) Post 302467574 by Scrutinizer on Saturday 30th of October 2010 02:15:27 AM
Old 10-30-2010
Try this for a starter:
Code:
i=1
while grep -qxF "$name1:$name2:$name3:$i" infile
do 
  i=$(( i+1 ))
done
printf "%s\n" "$name1:$name2:$name3:$i" >> infile

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Changing Unix form to Microsoft Word form to be able to email it to someone.

Please someone I need information on how to change a Unix form/document into a microsoft word document in order to be emailed to another company. Please help ASAP. Thankyou :confused: (8 Replies)
Discussion started by: Cheraunm
8 Replies

2. Shell Programming and Scripting

bash: testing if string is a number

How do you test if a string is a number? Trying to do something like this: x="AS" if( x is not a number ); then x=0 fi Because I want to do number arithmetic with x. (3 Replies)
Discussion started by: eur0dad
3 Replies

3. Shell Programming and Scripting

Changing Line Number of a File

Example: O o x What I would like to do is to rename the first column of the above file without affecting the format. The output should look like the following: Output: O o x #! /bin/ksh cd $HOME/lib/.Lee #nl = no. of lines. nl=`grep 'X' ex | wc -l` #ln = line no. ln=1 (17 Replies)
Discussion started by: ilak1008
17 Replies

4. Shell Programming and Scripting

exporting number into .csv file in text form (no other extra charc) from shell script

I have written a k shell program which is executing a sql and exporting data in numeric form like 0412323444 into .csv file. the problem i am facing is that , the data is coming in excel formatted in scientific form like 4.1+E08,while my requirement is to store data as such 0412323444 in excel ( no... (5 Replies)
Discussion started by: Deepak_Rastogi
5 Replies

5. Shell Programming and Scripting

Number/string format in bash

I would like to change the format of an integer type number adding zeros to the left of it in a script in bash. For example number=1 echo $number 00001 Thanks (3 Replies)
Discussion started by: josegr
3 Replies

6. Programming

Adding 2 difft int to form a number

got 1 problem.. can someone help me wit the logic? Money Money ::operator+(const Money &rhs)const { Money temp; temp.a = a+rhs.a; temp.b = b+rhs.b; return temp; }//end i got 2 number e.g 6.2 and 3.8 (1 Reply)
Discussion started by: xiaojesus
1 Replies

7. Shell Programming and Scripting

Changing the sequence number

Hi, I have a data as follow: 1 400 2 239 3 871 4 219 5 543 6 ... 7 ... .. ... .. ... 99 818 100 991 I want to replace the sequence number (column 1) that start from 150. The output should like this: 150 400 151 239 (3 Replies)
Discussion started by: nica
3 Replies

8. Shell Programming and Scripting

Changing one number in all files using awk

Hi I want to change the number 70 mentioned in my file to 76 by using awk. I know how to change all same digits but not one particular number. I have 29 files almost similar to this. One of my files looks like #Input file for 200K NPT molecular dynamics of final 70%XL made from 58.5%... (3 Replies)
Discussion started by: ananyob
3 Replies

9. Shell Programming and Scripting

Taking largest (negative) number from column of coordinates and adding positive form to every other

Hello all, I'm new to the forums and hope to be able to contribute something useful in the future; however I must admit that what has prompted me to join is the fact that currently I need help with something that has me at the end of my tether. I have a PDB (Protein Data Bank) file which I... (13 Replies)
Discussion started by: crunchgargoyle
13 Replies

10. Shell Programming and Scripting

Decimal conversion number of the form x.xx to 0x.xx, sed?

Hello I have a file of the form ... num 0.12 num num num 25.53 num num num 7.82 num num ...... and I want to convert the 2nd field of each line adding a "0" at the numbers >= 0 and < 10 so the output will have the form: ... num 00.12 num num num 25.53 num num num 07.82 num... (10 Replies)
Discussion started by: phaethon
10 Replies
Mojo::Base(3pm) 					User Contributed Perl Documentation					   Mojo::Base(3pm)

NAME
Mojo::Base - Minimal base class for Mojo projects SYNOPSIS
package Cat; use Mojo::Base -base; has 'mouse'; has paws => 4; has [qw(ears eyes)] => 2; package Tiger; use Mojo::Base 'Cat'; has stripes => 42; package main; use Mojo::Base -strict; my $mew = Cat->new(mouse => 'Mickey'); say $mew->paws; say $mew->paws(5)->ears(4)->paws; my $rawr = Tiger->new(stripes => 23); say $rawr->ears * $rawr->stripes; DESCRIPTION
Mojo::Base is a simple base class for Mojo projects. # Automatically enables "strict", "warnings" and Perl 5.10 features use Mojo::Base -strict; use Mojo::Base -base; use Mojo::Base 'SomeBaseClass'; All three forms save a lot of typing. # use Mojo::Base -strict; use strict; use warnings; use feature ':5.10'; # use Mojo::Base -base; use strict; use warnings; use feature ':5.10'; use Mojo::Base; push @ISA, 'Mojo::Base'; sub has { Mojo::Base::attr(__PACKAGE__, @_) } # use Mojo::Base 'SomeBaseClass'; use strict; use warnings; use feature ':5.10'; require SomeBaseClass; push @ISA, 'SomeBaseClass'; use Mojo::Base; sub has { Mojo::Base::attr(__PACKAGE__, @_) } FUNCTIONS
Mojo::Base exports the following functions if imported with the "-base" flag or a base class. "has" has 'name'; has [qw(name1 name2 name3)]; has name => 'foo'; has name => sub {...}; has [qw(name1 name2 name3)] => 'foo'; has [qw(name1 name2 name3)] => sub {...}; Create attributes, just like the "attr" method. METHODS
Mojo::Base implements the following methods. "new" my $object = BaseSubClass->new; my $object = BaseSubClass->new(name => 'value'); my $object = BaseSubClass->new({name => 'value'}); This base class provides a basic object constructor. You can pass it either a hash or a hash reference with attribute values. "attr" $object->attr('name'); BaseSubClass->attr('name'); BaseSubClass->attr([qw(name1 name2 name3)]); BaseSubClass->attr(name => 'foo'); BaseSubClass->attr(name => sub {...}); BaseSubClass->attr([qw(name1 name2 name3)] => 'foo'); BaseSubClass->attr([qw(name1 name2 name3)] => sub {...}); Create attributes. An array reference can be used to create more than one attribute. Pass an optional second argument to set a default value, it should be a constant or a sub reference. The sub reference will be excuted at accessor read time if there's no set value. DEBUGGING
You can set the "MOJO_BASE_DEBUG" environment variable to get some advanced diagnostics information printed to "STDERR". MOJO_BASE_DEBUG=1 SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Base(3pm)
All times are GMT -4. The time now is 03:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy