Sponsored Content
Top Forums Shell Programming and Scripting changing number in bash (number is in form of string) Post 302468435 by Learnerabc on Tuesday 2nd of November 2010 05:53:22 PM
Old 11-02-2010
Quote:
Originally Posted by Scrutinizer
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

Sorry one problem with this...

What this is doing is
sam:harry:joseph:1 (when i first add the name)

when i enter the same three names it updates that 2 butoutput in the file is like this:
sam:harry:joseph:1 (the one tht we did first)
sam:harry:joseph:2 (number changed)
what i want is it should not skip to next like and change 1 to 2 from the same line which was already stored.

any help will be appreciated
Thanks
 

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
SYMLINK(2)							System Calls Manual							SYMLINK(2)

NAME
symlink - make symbolic link to a file SYNOPSIS
symlink(name1, name2) char *name1, *name2; DESCRIPTION
A symbolic link name2 is created to name1 (name2 is the name of the file created, name1 is the string used in creating the symbolic link). Either name may be an arbitrary path name; the files need not be on the same file system. RETURN VALUE
Upon successful completion, a zero value is returned. If an error occurs, the error code is stored in errno and a -1 value is returned. ERRORS
The symbolic link is made unless on or more of the following are true: [ENOTDIR] A component of the name2 prefix is not a directory. [EINVAL] Either name1 or name2 contains a character with the high-order bit set. [ENAMETOOLONG] A component of either pathname exceeded 255 characters, or the entire length of either path name exceeded 1023 characters. [ENOENT] The named file does not exist. [EACCES] A component of the name2 path prefix denies search permission. [ELOOP] Too many symbolic links were encountered in translating the pathname. [EEXIST] Name2 already exists. [EIO] An I/O error occurred while making the directory entry for name2, or allocating the inode for name2, or writing out the link contents of name2. [EROFS] The file name2 would reside on a read-only file system. [ENOSPC] The directory in which the entry for the new symbolic link is being placed cannot be extended because there is no space left on the file system containing the directory. [ENOSPC] The new symbolic link cannot be created because there there is no space left on the file system that will contain the sym- bolic link. [ENOSPC] There are no free inodes on the file system on which the symbolic link is being created. [EDQUOT] The directory in which the entry for the new symbolic link is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. [EDQUOT] The new symbolic link cannot be created because the user's quota of disk blocks on the file system that will contain the symbolic link has been exhausted. [EDQUOT] The user's quota of inodes on the file system on which the symbolic link is being created has been exhausted. [EIO] An I/O error occurred while making the directory entry or allocating the inode. [EFAULT] Name1 or name2 points outside the process's allocated address space. SEE ALSO
link(2), ln(1), unlink(2) 4.2 Berkeley Distribution August 26, 1985 SYMLINK(2)
All times are GMT -4. The time now is 05:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy