10-30-2010
changing number in bash (number is in form of string)
I have a txt file as database. when i run my program what it does is it ask me for 3 name and stored in the file as
name1:name2:name3:1
when u enter 3 name it add those in file as above format and add 1 at the end. I what i want is if i enter same names again it changes that 1 to 2 and so on..but if i enter different names than it add those in a fiile with 1 at the end.. any idea will be apreciated
message for mod: I ask this kind of question in one of my other thread but that thread was about something else. So if this is not allowed to ask again even though the topic is different. please delete the post..Thanks
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
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
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
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
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
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
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
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
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
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
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
link(2) System Calls Manual link(2)
Name
link - link to a file
Syntax
link(name1, name2)
char *name1, *name2;
Description
A hard link to name1 is created; the link has the name name2. The name1 must exist.
With hard links, both name1 and name2 must be in the same file system. Unless the caller is the superuser, name1 must not be a directory.
Both the old and the new share equal access and rights to the underlying object.
Return Values
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned, and errno is set to indicate the error.
Diagnostics
The system call fails and no link is created under the following conditions:
[ENOTDIR] A component of either path prefix is not a directory.
[ENAMETOOLONG] A component of either pathname exceeded 255 characters, or the entire length of either pathname exceeded 1023 characters.
[ENOENT] A component of either path prefix does not exist.
[ENOENT] The file named by name1 does not exist.
[ENOENT] When name1 or name2 point to an empty string and the environment defined is POSIX or SYSTEM_FIVE.
[EACCES] A component of either path prefix denies search permission.
[EACCES] The requested link requires writing in a directory with a mode that denies write permission.
[EEXIST] The link named by name2 does exist.
[EPERM] The file named by name1 is a directory, and the effective user ID is not that of superuser or the environment defined is
POSIX.
[EXDEV] The link named by name2 and the file named by name1 are on different file systems.
[EROFS] The requested link requires writing in a directory on a read-only file system.
[EFAULT] One of the pathnames specified is outside the process's allocated address space.
[ELOOP] Too many symbolic links were encountered in translating one of the pathnames.
[ENOSPC] The directory in which the entry for the new link is being placed cannot be extended because there is no space left on the
file system containing the directory.
[EDQUOT] The directory in which the entry for the new 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.
[EIO] An I/O error occurred while reading from or writing to the file system to make the directory entry.
[ESTALE] The file handle given in the argument is invalid. The file referred to by that file handle no longer exists or has been
revoked.
[ETIMEDOUT] A connect request or remote file operation failed because the connected party did not properly respond after a period of
time that is dependent on the communications protocol.
[EMLINK] The number of links to the file named by path1 would exceed {LINK_MAX}.
Environment
In the POSIX environment, linking to directories is not allowed.
See Also
symlink(2), unlink(2)
link(2)