Whne I tried as below code, no is giving the 0 value and for that resion not getting any value from array. Please help me on this...
OUTPUT like :
0
After spliting
hi i am trying to save values in a file in an array in awk..the file is as follows:
0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,
so far i have this:
awk 'BEGIN {RS="\n";FS=","}
{
for(i=1;i<=NR;i++)
{
for(j=1;j<=NF;j++)
{
a=$j;
}
} (4 Replies)
I am beginner in awk
awk 'BEGIN{for(i=1;(getline<"opnoise")>0;i++) arr=$1}{print arr}'
In the above script, opnoise is a file, I am reading it into an array and then printing the value corresponding to index 20. Well this is not my real objective, but I have posted this example to describe... (19 Replies)
Is there a way to have awk put successive records into an array in a bash script?
I have files that say things like
name :title :salary
Bob :Instructor :30,000
Joyce :Instructor :30,000
Patrick :Manager :40,000
What I want to do is seperate this file into an array so that... (8 Replies)
Hi, as the title, I have an array @f_lines with gene information in it. How can I put the content of @f_lines into a file so that I can read it?
I tried this:
open(OUTPUT, "file"); # put gene information in this file;
@f_lines = ("gene1", "gene2", "gene3"...); # gene information;
print... (3 Replies)
Hi all,
I been looking for a solution to the fact that when I use:
for (i=1; i<=NF; i++) print $ifields that are originally in a single line are printed in a single line
I have severals files for which the first 7 are the same, but the number of variables after that can vary, for example NF... (5 Replies)
Hi ,
I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code.
my $current_value=12345;
my @users=("bob","ben","tom","harry");
open DBLIST,"<","/var/tmp/DBinfo";
my @input = <DBLIST>;
foreach (@users)
{
my... (11 Replies)
Hi,
I have the following input in a file & need output as mentioned below(need counter of every occurance of field which is to be increased by 1).
Input:
919143110065
919143110065
919143110052
918648846132
919143110012
918648873782
919143110152
919143110152
919143110152... (2 Replies)
Hello,
May i please know how do i print the array using awk script. I am using below shell script to start with but not working.
#!/bin/bash
LOADSTATUS="Line 0"
LOADSTATUS="Line 1"
LOADSTATUS="Line 2"
LOADSTATUS="Line 3"
LOADSTATUS="Line 4"
awk '
BEGIN {
Your File Load Status
}... (1 Reply)
for a in {1..100}
do
awk '{ sum+=$a} END {print sum}' a=$a file1 > file2
done
I know I will get only one number if following the code above, how can I get 100 sum numbers in file2? (2 Replies)
In the below awk I am splitting $7 on the : and then counting each line or NM_xxxx. If the $1 value is the same for each line then print the $7 that occurs the most with the matching $1 value. The awk seems close but I am not sure what is going on. I included a description as well as to what I... (1 Reply)
Discussion started by: cmccabe
1 Replies
LEARN ABOUT PHP
dirname
DIRNAME(3) 1 DIRNAME(3)dirname - Returns parent directory's pathSYNOPSIS
string dirname (string $path)
DESCRIPTION
Given a string containing the path of a file or directory, this function will return the parent directory's path.
PARAMETERS
o $path
- A path. On Windows, both slash ( /) and backslash ( ) are used as directory separator character. In other environments, it is
the forward slash ( /).
RETURN VALUES
Returns the path of the parent directory. If there are no slashes in $path, a dot (' .') is returned, indicating the current directory.
Otherwise, the returned string is $path with any trailing /component removed.
CHANGELOG
+--------+-------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+-------------------------------+
| 5.0.0 | |
| | |
| | dirname(3) is now binary safe |
| | |
+--------+-------------------------------+
EXAMPLES
Example #1
dirname(3) example
<?php
echo "1) " . dirname("/etc/passwd") . PHP_EOL; // 1) /etc
echo "2) " . dirname("/etc/") . PHP_EOL; // 2) / (or on Windows)
echo "3) " . dirname("."); // 3) .
?>
NOTES
Note
dirname(3) operates naively on the input string, and is not aware of the actual filesystem, or path components such as " ..".
Note
dirname(3) is locale aware, so for it to see the correct directory name with multibyte character paths, the matching locale must be
set using the setlocale(3) function.
Note
Since PHP 4.3.0, you will often get a slash or a dot back from dirname(3) in situations where the older functionality would have
given you the empty string.
Check the following change example:
<?php
//before PHP 4.3.0
dirname('c:/'); // returned '.'
//after PHP 4.3.0
dirname('c:/x'); // returns 'c:'
dirname('c:/Temp/x'); // returns 'c:/Temp'
dirname('/x'); // returns ''
?>
SEE ALSO basename(3), pathinfo(3), realpath(3).
PHP Documentation Group DIRNAME(3)