Search Results

Search: Posts Made By: mobitron
3,029
Posted By mobitron
mirko - See my post #22 above.
mirko -
See my post #22 above.
3,029
Posted By mobitron
So those ^M characters are your problem. Always...
So those ^M characters are your problem. Always use an editor like vi to create shell scripts, not a Windows editor like Notepad. To get rid of these, run:

tr -d '\r' < bashScriptTest.sh >...
3,029
Posted By mobitron
I suspect you have DOS newline characters in your...
I suspect you have DOS newline characters in your script which is causing it to behave incorrectly. Can you give the output of:
cat -vet bashScriptTest.sh
9,588
Posted By mobitron
I was indeed mistaken. Thanks for putting me...
I was indeed mistaken. Thanks for putting me straight!
9,588
Posted By mobitron
2 things are wrong - 1. You are missing a...
2 things are wrong -
1. You are missing a double quote in your expression (echo $VAR1")
2. Your test expression can't just be the output of the grep command - you need to perform some kind of test...
9,588
Posted By mobitron
/usr/bin/sh on Solaris is plain Bourne shell, not...
/usr/bin/sh on Solaris is plain Bourne shell, not bash. "[[" and "]]" will not work on this shell. You need to explicitly set a bash shell in your shebang or use "[" "]" for your test operator.
9,588
Posted By mobitron
The error means that your shell does not...
The error means that your shell does not recognise "[[" as a command, which means it is not a bash shell. Make sure the top line of your script is :

#!/bin/bash
2,420
Posted By mobitron
echo <string> | sed "s/Cluster//"
echo <string> | sed "s/Cluster//"
1,386
Posted By mobitron
#!/usr/bin/bash for result in a b c d e f ...
#!/usr/bin/bash

for result in a b c d e f
do
echo "${result}=$(grep -c $result list.txt)"
done


Result:


a=3
b=0
c=2
d=2
e=1
f=1
1,208
Posted By mobitron
This is not how grep works. By default, grep...
This is not how grep works. By default, grep takes a file as its input. Your code is telling grep to look in a file named "for(i=1;i<=10;i++)", which obviously won't work.

Instead, echo the text...
1,208
Posted By mobitron
echo "haighaihaihai" | grep -o...
echo "haighaihaihai" | grep -o "hai"
4,949
Posted By mobitron
Maybe myprogram behaves differently if it is run...
Maybe myprogram behaves differently if it is run from a different directory. Try running myprogram interactively from the command line using:

$HOME/here/lives/code/myprogram

Does it behave the...
1,832
Posted By mobitron
The test is returning "too many arguments"...
The test is returning "too many arguments" because you have passed it too many arguments. This is an instance where you want to use backticks, because you need to pass the output of the grep command...
1,832
Posted By mobitron
You should use them when you want to pass the...
You should use them when you want to pass the output of what is within the quotes to another command, or a variable assignment.

e.g. if you wanted to assign the content of the user's passwd entry...
1,832
Posted By mobitron
You need to remove the backticks as well: ...
You need to remove the backticks as well:


if grep $username /etc/passwd > /dev/null
1,832
Posted By mobitron
This will attempt to run the value of $username...
This will attempt to run the value of $username as a command, which is not what you want to do. You probably want to do



echo $username >> information_file



You should also validate...
1,803
Posted By mobitron
Make sure your script contains only Unix-style...
Make sure your script contains only Unix-style end-of-line characters.

cat -vet main1.sh

You should only see


#!/bin/sh$
while read DAYS INDIR OUTDIR$
do$
find $INDIR -type f "!" -mtime...
21,868
Posted By mobitron
1. You are using a numeric comparision operator...
1. You are using a numeric comparision operator (-eq) to compare strings.
2. Why don't you test for inequality instead of equality?
3. You are missing whitespace between your test arguments and...
30,960
Posted By mobitron
You have 2 issues here: 1. Your data is...
You have 2 issues here:
1. Your data is delimited by the "|" character so you need to specify this to awk with the -F argument:
awk -F "|" '{ if ( $2 > 50 || $3 > 50 || $4 > 50 || $5 > 50 ) print...
9,965
Posted By mobitron
OK, so I suspect the file is not in plain text...
OK, so I suspect the file is not in plain text format or doesn't contain any valid newline characters. Excel might have exported it in the wrong format.

Try the following

tr "\r" "\n" <...
9,965
Posted By mobitron
That works fine for me $ awk '{ print $3 }'...
That works fine for me

$ awk '{ print $3 }' xl.txt | more
161
PGP_JFY63
COC084
Addicts
M
42
-0.785714286
-0.785714286
-0.785714286
-0.785714286
-0.785714286
-0.785714286
2.214285714...
9,965
Posted By mobitron
Can you give some sample lines from the text file?
Can you give some sample lines from the text file?
Showing results 1 to 22 of 22

 
All times are GMT -4. The time now is 10:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy