I have a perl script with an array of clients.
@arr = ("The ABC Corp", "AA Corp.", "BB Corp");
If I run
@a = sort (@arr);
I will get
@a = ("AA Corp", "BB Corp", "The ABC Corp");
but I want
@a = ("AA Corp, "The ABC Corp", "BB Corp");
How do I sort array without changing... (2 Replies)
Some one plz help me how to sort an array of hashes .....
for e.g i have an array as
@AoH = (
{
ques => 10,
marks => 32,
},
{
ques => 32,
marks => 22,
},
{
ques => 2,
marks => 41,
},
);
now i want to sort this array with increasing value of "ques" ..... plz... (3 Replies)
Hey
How do I sort an array numerically after the second column?
My values are integers like 1, 2, 3, 4... and they are not unique, so I can't just reverse my hash and sort by keys.
I wanna sort my file/array so that I get the lines with the highest value in the top - that is descending. ... (2 Replies)
Hello to everyone!
I'm really new in shell scripting and I'm experiencing a very odd problem. This is my first post in this forum, hope you can help!
I know that declaring arrays in Bourne Shell is impossible. But this is where I start having problems - system administrator did not install... (8 Replies)
Hi Everyone,
Any simple code can simplify the code below, please advice. Thanks
# cat 2.pl
#!/usr/bin/perl
use warnings;
use strict;
my @aaaaa = <DATA>;
my @uids;
foreach (@aaaaa) {
my @ccccc = split (",", $_);
push @uids, $ccccc;... (3 Replies)
Hi I'm just learning programming and need some help.
I've taken a data file which has a list of numbers eg:
3
5
32
533
13
2
And I've used sort -n and to sort and then piped it to awk to arrange into an array.
#!/bin/sh
sort -n data.txt |
awk '
{
array=$1
} (4 Replies)
Hi,
I'm new to linux & bash so please forgive my ignorance, just wondering if anyone can help.
I have a file (mainfile.txt) with comma deliminated values, like so:
$1 $2 $3
613212, 36, 57
613212, 36, 10
613212, 36, 10
677774, 36, 57
619900, 10, 10
i need to split this file... (12 Replies)
Hi,
input:
line1|error_type_a@15
line1|error_type_c@10
line1|error_type_b@5
line2|error_type_f@3
line2|error_type_a@1
I would need to place all the second fields with common first field on the same line, BUT with sorted error position number:
line1|error_type_b@5; error_type_c@10;... (5 Replies)
Hi there,
I'm listing files and sorting them. When I try to get length of array variable in which these files are stored I get 1 as value. That's weird.
files_info="$(find $input_dir -name "*_CHR$i.info" | sort )"
printf ${#files_info}"\n" #print length
#--loop through... (6 Replies)
Hello
I have a problem.
I create a Multidimensional Array Like this:
ENTRY="$kunnum-$host"
ENTRY="$host"
ENTRY="# $3"
for key in "${!ENTRY}"; do
ENTRIES=${ENTRY} # INDEX=IP(5)
donedeclare -p
declare -A ENTRIES=(="unas15533" ="unas" ="# RDP-Terminal 2"... (12 Replies)
Discussion started by: Marti95
12 Replies
LEARN ABOUT PLAN9
grep
GREP(1) General Commands Manual GREP(1)NAME
grep - search a file for a pattern
SYNOPSIS
grep [ option ... ] pattern [ file ... ]
DESCRIPTION
Grep searches the input files (standard input default) for lines (with newlines excluded) that match the pattern, a regular expression as
defined in regexp(6). Normally, each line matching the pattern is `selected', and each selected line is copied to the standard output.
The options are
-c Print only a count of matching lines.
-h Do not print file name tags (headers) with output lines.
-i Ignore alphabetic case distinctions. The implementation folds into lower case all letters in the pattern and input before interpre-
tation. Matched lines are printed in their original form.
-l (ell) Print the names of files with selected lines; don't print the lines.
-L Print the names of files with no selected lines; the converse of -l.
-n Mark each printed line with its line number counted in its file.
-s Produce no output, but return status.
-v Reverse: print lines that do not match the pattern.
Output lines are tagged by file name when there is more than one input file. (To force this tagging, include /dev/null as a file name
argument.)
Care should be taken when using the shell metacharacters $*[^|()= and newline in pattern; it is safest to enclose the entire expression in
single quotes '...'.
SOURCE
/sys/src/cmd/grep.c
SEE ALSO ed(1), awk(1), sed(1), sam(1), regexp(6)DIAGNOSTICS
Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs.
GREP(1)