what's the point of the for loop... num is already an array
Type: Posts; User: Mia_tech; Keyword(s):
what's the point of the for loop... num is already an array
is this a good way to check whether a file exist or not? and then delete it
echo -n "Enter file name: "
read fileName
for i in *
do
if [ -f $i ] && [ $i == $fileName ]; then
rm...
Enter a list of numbers: 2 10 34 44 20
then iterate through the numbers and add them to an array... doesn't have to be (while read) any other method is fine, but
read -a numbers I'm looking for...
I tried this method too, after entering numbers I press enter and terminal is waiting for more input...
with this method, after you enter the numbers and press enter the terminal is still waiting for input.... something is missing
what is the best way to read a line containing multiples numbers into an array.
I know "read -a numbers" will put all numbers into the numbers array. But I want to read every number and put them...
I think the best way is to pass the arguments like: "10 \* 10", even though is a single param when you pass it to a functions you can still break it down into $1 $2 $3
Thanks
yeah, I tried that (script.sh 10 \* 2) but I'm getting errors. Also if I use either "" or ' ' it will interpret the parameters as a single parameter right?
very efficient algorithm!..
Thanks
I have a simple script which takes three parameters in the form of
./script.sh 10 * 2
and produces an output, the script works find; however, it doesn't work when using multiplication 10 * 2. I...
great job!.. would you mind explaining this two sentences
row="${row%?}*"
row="${row#?}**"
I know it is a variable declaration, but what's on the right side of "=" sign I haven't seen it yet
I'm trying to draw a tree in the following form
*
***
*****
*******
*********
as you can see I need both spaces, and "*" stars in every line, but I can't get it quite the...
how about if I only wanted to display the words and not the size?
guys, I have a text file with words, and I want to put them into an array and sort them based on string length/size of every word. I wonder if there's a command that would allow me to do this, so I...
no I have to do it from a command line/script. I just was looking for a command, so I wouldn't have to write an algorithm to do it
thanks
I have a text file with words, and I would like to sort it by word length/size. I checked the sort commands for any option that would allow me to do this, but none seem to work.
thanks
I'm getting unexpected eof, but I don't see the error
#!/bin/bash
#passing and returning arrays from functions
#calculating total sum
times_two() {
local oarray=($(echo $@))
local...
yeah, the index in my array was wrong!... I changed it to this and worked
times_two() {
local oarray=($(echo $@))
local newarray=($(echo $@))
i=0
while [ $i -lt $# ]
do...
I have the following script that pretty much check for the status of motion daemon and based on that it stop it or start the daemon, I have added the command along with my username to sudoers file so...
I'm getting errors when trying to multiply by 2.
#!/bin/bash
#passing and returning arrays from functions
#calculating total sum
times_two() {
local oarray=(`echo $@`)
local...
I have the following script and I'm getting: too many arguments error
#!/bin/bash
#creating new dir and copy files into it
create_dir() {
if [ $# -eq 0 ]; then
echo "Usage: $0 param1...
guys, the toArray method is not working, could someone tell me why
Thanks
package com.javablackbelt.utils;
import java.util.ArrayList;
import java.util.Arrays;
import...
nope, but the whole file is commented out...
I've tried different tty1...6 with same results
yeah, I'm getting authentication failure in the logs... but I'm able to login to my X session, and sudo password works too
Oct 22 18:36:08 computer1 login[1216]: pam_unix(login:auth):...