General :: Comparing Arrays In Bash ?

Jun 2, 2010

Is there a way to compare an array in a while conditions?

I have one array that contains the results of some search and if the script has found all the items, then it should stop, so my idea is to have a while loop � la:


Code:

View 4 Replies


ADVERTISEMENT

General :: Compare Two Arrays In Bash?

Sep 30, 2010

I am writing a script to get the multiples of 2 and 3, place them in an 2 arrays, and then show the common integers. So far everything works fine till the comparision. I don't know how to compare them. Here is the code:

Code:

#!/bin/bash
let num1="2"
let num2="3"

[code]...

View 6 Replies View Related

General :: Comparing Files In Bash Script

Sep 2, 2010

I want to compare two files and display values unique to file1. I tried using comm but it did not give me useful outputs.

comm -2 -3 file1 file2 does not work

Similar threads provide matched content. What I am looking for is unique content.

View 9 Replies View Related

General :: Bash Scripts - Comparing Multiple Items Or Conditions Using 'if' Statements?

Mar 12, 2011

comparing multiple items or conditions using 'if' statements? I want to do something if one or more conditions is true, for example:

If a = 1 or b = 1.

I've tried:

[Code]...

View 5 Replies View Related

Programming :: Initializing Arrays In The Bash?

Mar 12, 2009

I'm making script for automated compiling of one program which would output builds optimized for many architectures. For clearancy, I do each build in it's own catalogue and list of builds with their respective catalogues would be stored as array. I'm using this guide as reference. It describes making array as naming a variable with additional brackets denoting it's position in array.

In my code, it looks exactly like this:

Code:

mtune[1]="build/mtune/athlon"
mtune[2]="build/mtune/athlon-4"
mtune[3]="build/mtune/athlon-mp"

[code]....

But upon invoking $mtune or any $mtune[x] variable, output is blank, like the variable(s) were never initialized. What am I doing wrong?

View 1 Replies View Related

Software :: Bash Arrays And Quotes (PvPGN)

Aug 23, 2010

I am trying to get PvPGN working... I have installed all the files, the only thing now is that bntrackd wants to use 'logs/bntrackd.log' for it's logfile, but seeing as it's in /usr/sbin, I want it to use /var/log/bntrackd. This is done with 'bntrackd --logfile=/var/log/bntrackd.log' but when I put that in the script it won't process it as a command (instead splitting it and complaining that I don't have --logfile=/var/log/bntrackd.log installed)

/etc/rc.d/pvpgn:

Code:
#!/bin/bash
...
[ -z "$PVPGN_DAEMONS" ] && PVPGN_DAEMONS=(bnetd d2dbs d2cs)
...
for d in ${PVPGN_DAEMONS[@]}; do

[Code]....

View 4 Replies View Related

Programming :: Bash: Combine Arrays & Delete Duplicates?

May 23, 2011

I would like to combine two arrays and delete duplicates that might occur. I tried to solve it like this:

Code:
combined=( "${results1[@]}" "${results2[@]}" )
printf "${combined[@]}" | sort -n | uniq
Example:
result1 (4 elements):

[Code]....

In my code printf seems to have a problem with elements that have the same letters but a space inbetween. For instance "new foo", "newfoo" are the same for printf

View 5 Replies View Related

Programming :: Bash Scripting Arrays And Indirect Referencing

Feb 23, 2010

I've got a situation. I'm having GNU bash version 3.00.16(1) on Solaris 10. I need to declare an array say arr1 which will be populated by an output of a command.

declare -a arr1
arr1=( $(/some/command) )

Supposing it will eventually (after executing the command) have element values as -

arr1[0]=1234
arr1[1]=5678
arr1[2]=7890

Now, I need to declare another set of arrays, one for each of the element values above - e.g.

declare -a arr1_1234
declare -a arr1_5678
declare -a arr1_7890

And I also need to populate elements of each of above 3 arrays with output of another command in a loop. So, these arrays will hold values something like -

arr1_1234[0]="abc"
arr1_1234[1]="def"
arr1_1234[2]="ghi"

arr1_5678[0]="jkl"
arr1_5678[1]="mno"
arr1_5678[2]="pqr"
arr1_7890[0]="tuv"
arr1_7890[1]="xyz"
arr1_7890[2]="aab"

I'm able to declare and populate arr1[*]. My question is how do I declare, populate and print the subsequent arrays and their elements?I am feeling rather thick to get this working.

View 7 Replies View Related

Programming :: Bash Script - Merge Files Comparing Columns

Apr 13, 2011

I have 2 very long files which are quite similar:

file1.csv:

Code:

file2.csv:

Code:

I need this output:


Code:

explanation:

If the fields 3 (serie) and 4 (modello) are identical, the lines of the 2 files should be "added":

Code:

If the fields 3 (serie) and 4 (modello) are different, just print the line of both files:

Code:

Is there a way to do this without reading the (huge) files with a "while read line" loop?

View 14 Replies View Related

Programming :: Bash File Comparing - Report How Many Matching Words My Main File ?

Jun 9, 2009

I have been messing with diff and grep for 2 days now without result

I am trying to match a file consisting of words to many separate other wordfiles in a specific directory. one by one.

What i want the script to do is to report how many matching words my main file has with every file in the directory, each in turn

setup:

Each of em are plain text files with 1 word per line

Output should be something like:

SCRIPT REPORT:

View 8 Replies View Related

General :: Comparing Resources Using Top?

Apr 6, 2011

Fedora 15 Alpha

3861 user 20 0 904m 128m 33m S 0.7 6.4 1:11.52 xulrunner-bin
1323 user 20 0 1555m 95m 31m S 13.5 4.8 4:06.87 gnome-shell
3494 user 20 0 1028m 50m 21m S 12.8 2.5 1:43.32 evolution

I just wondering what is the difference between RES, SHR, and VIRT.

1) The VIRT always seems to be higher. Is this using the paging file system. (virtual memory on the harddisk, the swap memory)

2) Is the RES memory the actual physical RAM memory?

3) Is shared memory sharing memory with other processes?

4) Just a final question. As I am running on a HP Mini 210, memory and CPU is a resource I don't have a abundence of. So if was to compare for example 2 difference browsers i.e. firefox and midora. What should I brench mark between to 2 to find what one uses less resources?

View 2 Replies View Related

General :: Comparing Multiple Of Files ?

Mar 20, 2010

I am fairly new to Linux and was needing some help on a comparing more than 2 files. I am try to come up with something that would compare at least 10+ different files to a master file and give me an output of what is missing.

Example would be: a.txt, b.txt, c.txt, d.txt compare each of them to the master.txt file, than output the missing text for each file into new file.

I came across comm and diff commands, am I looking in the right place or is there a much easier way of doing this?

View 2 Replies View Related

General :: Comparing Two Fields In Two Files Using Awk?

Jul 12, 2011

I have a file1:

Code:

$ cat PF(1).out
Tmp39 PF10271.3 423 ENSP00000326063 488 1.2e-201 41-478
Tmp39 PF10271.3 423 ENSP00000338165 492 1.9e-200 46-479

[code].....

View 14 Replies View Related

General :: Comparing Lines In 2 Text Files?

Nov 5, 2010

Is there a way, besides writing a PERL program, to read each line one by one in file A and tell if this line also exists in file B? Can this be done via a shell script?

View 6 Replies View Related

General :: Comparing A File Size To A Given Number?

Jul 26, 2011

I'm trying to write a script that takes two arguments, the first argument is a number, and the second argument is a filename. The shell script should indicate if the file's size is BIGGER or SMALLER the number provided. this is what i have sofar, am i on the write track, i'm hoping its just a problem with my if command

if [ $1 -h $2 ]
then
echo "$1 is bigger than $2"
else

[code]....

View 2 Replies View Related

General :: Comparing All The Files In A Directory By Content?

Sep 18, 2010

I wish to compare all the files in a directory....comparing is by content. And same files should be printed...

echo "program : $0"
cd $1
for a in *
do

[code]....

This logic did not give the correct result...

View 5 Replies View Related

General :: Comparing Two Files For Differences And Similarities

Jul 26, 2010

Iam having the following two linux files.

[Code]...

Now i want the following out puts

1. similar nos in both the file 1 and file 2 > output= File 3;
2. In file 1, but not in file 2 > out put= file 4;
3. In file 2, but not in file 1 > output = file 5;

The command sdiff is giving output with symbols > < | etc, and the such output file is not clear and ready to print. I want to print directly the output files. AND ALSO TELL ME WHERE I HAVE TO WRITE AWK PROGRAMS AND HOW TO RUN IT.

View 5 Replies View Related

General :: E2fsck Two External Arrays At Once?

Mar 11, 2011

If I umount both of them, can I run an e2fsck on each at the same time through 2 putty sessions, or will that not really gain me anything from doing them one after another?

View 3 Replies View Related

General :: Comparing Directories To Check All Stuff Copied?

Jul 4, 2010

I have recently backed up all my documents photos etc to an external hard drive. What is the best way to check that everything has copied? I have tried diff but it was not very clear.

View 7 Replies View Related

General :: New Features In RHEL6 Comparing To Its Older Versions?

Nov 19, 2010

what new features in RHEL6 comparing to its older versions??

View 4 Replies View Related

General :: Comparing Files - Change The Case Of The Letters In File1.txt

Nov 8, 2009

Two files contain:

file1:
cat
dog
fish
hamster

file2:
cat
fish
ferret
dog

How do you change the case of the letters in file1.txt to uppercase and compare with file2 all in one command?

View 2 Replies View Related

General :: Comparing Two Files - Display The User Names That Are In The First File And Not The Second

Sep 17, 2009

Im trying to compare two files and I only want to display the user names that are in the first file and not the second.

So I have one file named final.txt (which contains every user name and only the user names in a list no other information)

Then I have another file Over1.txt (which only contains certain users that have different permissions This file is also setup differently with the user name and some information about the user after the user name.

I need a way to compare final.txt to over1.txt so that I will only display the names that are in final.txt but not Over1.txt

Ive tried using diff and comm but just cant seem to get it two work correctly. Im not sure if im missing a option or what.

View 5 Replies View Related

General :: Accessing Arrays Position In A Split String?

Mar 10, 2011

I've a string "this.is.a.name", and I would like to put it in an array. But, I've like to print the output of the array as:

Code:
echo ${array[0]}
echo ${array[1]}
echo ${array[2]}
echo ${array[3]}
I've tried with

[Code]....

View 4 Replies View Related

General :: Raid Devices Not Creating Arrays / Solution For This?

Mar 30, 2010

I have created software raid 5 configurations on the second harddrive its working fine and i have edited fstab file for auto mounting when it reboot but when i reboot the computer raid doesn't work i have to re-create the arrays by typing "mdadm --create" command again and mount again manually ,is there anywhere i can do this once without retyping the commands again after rebooting and i am also using redhat 5

View 1 Replies View Related

General :: Scsi RAID Jbod And Arrays - Disk Utilization And The Corresponding Low Data Transfer

Jul 6, 2010

So I have a system that is about 6 years old running Redhat 7.2 that is supporting a very old app that cannot be replaced at the moment. The jbod has 7 Raid1 arrays in it, 6 of which are for database storage and another for the OS storage. We've recently run into some bad slowdowns and drive failures causing nearly a week in downtime. Apparently none of the people involved, including the so-called hardware experts could really shed any light on the matter. Out of curiosity I ran iostat one day for a while and saw numbers similar to below:

[Code]...

Some of these kinda weird me out, especially the disk utilization and the corresponding low data transfer. I'm not a disk IO expert so if there are any gurus out there willing to help explain what it is I'm seeing here. As a side note, the system is back up and running it just runs sluggish and neither the database folks nor the hardware guys can make heads or tails of it. Ive sent them the same graphs from iostat but so far no response.

View 1 Replies View Related

General :: Write A Literal Bash Command In A Bash File?

Nov 29, 2010

I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:

Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END

[code]...

View 6 Replies View Related

General :: Running Bash But Common Bash Commands Not Working?

Jul 17, 2010

below are the details of my system. I have bash as my current shell, some really common commands aren't working.

Do I need to do a re-installation of bash? Or how do I install a selection of bash commands which I need? (for example a subset of [URL])

Code:
root@sdptfw:~ # uname -a
Linux sdptfw.sdpt.co.za 2.4.36 #1 Tue Jul 22 13:13:24 GMT 2008 i686 i686 i386 GNU/Linux
root@sdptfw:~ # echo $SHELL$
/bin/bash$

[Code]....

View 13 Replies View Related

Programming :: Comparing Two Files ?

May 7, 2011

I have two files

Code:

we have to consider here $5 , $6 , $7 for our search

file2.txt

Code:

Here we should take only $2 for comparison. As you can most of the $2 field records has value and some do not have value.

Question:I want to take the fields $5 , $6 , $7 from file 1 and compare it with $2 field from file 2. and the rsult should be like this:

Code:

The final output will look like this

Actual file1.txt (before running the code)

Code:

FIle1.txt after running the above said condition

Code:

So the field $5 , $6 , $7 should get replaced from the matched valued of $1(file1)

View 3 Replies View Related

Red Hat / Fedora :: Searching And Comparing The String

May 18, 2010

I have a file which provide the output of all the applications which started and running successfully. But it doesn't give the Error message of the applications which are failed. For example there are 5 applications (ABC,DEF,NMO,STO,XYZ) and application STO failed so I will get the following output (out.txt). content of out.txt file

Application ABC is Running
Application DEF is Running
Application NMO is Running
Application XYZ is Running

I want to generate the text message based on the information on out.txt that STO application is Failed.

View 2 Replies View Related

Debian :: Comparing Contents Of Two Directories?

Mar 6, 2011

How to compare contents of 2 directories under squeeze?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved