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
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.
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 -
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.
I have about 1TB of data to sort out and need a good GUI package to find and safely delete the duplicate files. I am running Ubuntu 10.04 amd_64. Would appriciate any thoughts on how to get it done.
I have a fallowing CGI script, which does nothing more than prints out the values user inserted:
Code:
If I insert Martin to the name box and 192.168.1.1 to the IP box I get fallowing output:
Quote:
Name is Martin
IP address is 192.168.1.1
As you can see, script above works fine(I host this script in Apache server and use Firefox as a web-client). Now I made a fallowing bash script:
Code:
Which is started like this: ./script.sh Martin 192.168.1.1. Output is user name plus port numbers and descriptions. This bash script works fine as well
How can I combine those two scripts? I would like to insert name and IP to according boxes in Firefox and after clicking Generate button, user name plus list of port numbers and descriptions will appear in Firefox window instead of terminal emulator window
How to link/combine those two scripts to work together as one?
I would like to delete a single line from a file that contains many lines passing through the same values as the two parameters. Again, I would like to delete a single line and not all those that contain parameters. How can I make bash?
I prefer to delete trailing slahes from pathes. Until now I used sed:
Code: $ myPath=/home/ladygaga/// $ echo "$myPath" | sed 's//*$//' /home/ladygaga I played around to accomplish the same with on-board means of bash without using sed, but for example this line only deletes one trailing slash: Code: $ myPath=/home/ladygaga/// $ echo ${myPath%/*} /home/ladygaga// Is there a way to delete trailing slahes with just on-board means of bash?
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:
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:
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: #!/bin/bash f1=apple f2=banana f3=grape echo "Enter number 1,2 or 3:" # 3 is entered read x choice=${f+$x} # yielding choice=$f3 echo "$choice" # so $choice is, essentially, read as f3, which = grape
grape I am, essentially, trying to combine "f" and the number entered (3, for example) to create "f3", which when echoed as "$choice" will lead to grape!
I am working on a script that allows me to convert an IP address to a country name. I have 2 files. One that has text like: PORT.80 TCP SRC=x.x.x.x and the other is x.x.x.x United States. How can I combine these files so that the file output is PORT.80 TCP SRC=x.x.x.x United States?
I have a list of about 425 servers that are mostly redundant. I need to weed out the duplicate names so that I have a count of only the unique server hostnames. What is a good command to do this?
I have a problem on a program,the problem take a very long time when i try to add two big arrays element by elementI know that matlab make adding vectors more faster than adding element by element but I don't know how!!!do any body knew how matlab make vectors operations more faster than element by element???I want to make my calculation more faster because the program is very big
I was reading Kernighan Ritchie book chapter 4 which deals with character pointers.I am not able to understand following different type of declarations
Code: char aname[][15] = { "Illegal month", "Jan", "Feb", "Mar" }; char amessage[] = "now is the time";
need to process files within multiple directories and transfer these to a remote server. What I had in mind was to use arrays for this; code pasted below (explains it better):
Code: #set the arrays array_A=( fileA* pathtodestA hostA passwordA )
I have a Perl script that has two arrays - they are related. I would like to print out the contents into two columns next to each other.
#!/usr/bin/perl open(PINGFILE, </home/casper/pingdata.txt") or die " can not open file "; my @totalfile=<PINGFILE>; foreach $string(@totalfile) { if ($string =~ m/(^1sping)(?=.*max))/) { push(usecstring,"$string");
I am working on a project that needs to use structures and I'm pretty sure string arrays. First I declare my structures and they must be exactly like this.
a project using bluetooth to send data byte by byte to external devices buti'm not familiar using arrays to read file from another location before sending the data.If you could,do correct my codes.Here's my code,
I'm trying to figure out how to code for this specific type of instance - I want to use a hash and have the key be a reference to an array, and not use the key in the standard way of it being a scalar. Basically, I have a large output that I need to process line by line, and rather have access to it as an array than a big block in a scalar. For the big block hash as a scalar I would do -
How would I code it that I would have access to the key information as an array and not a scalar? I know it needs to be a pointer and we're going to have -> in there somewhere, but not sure how to approach it. Some of the documentaiton I've been reading about referencing I've found a little confusing so far, and trying to figure out how to use them in context of what I'm working on.