I have this command succession:
echo -ne "/dev/shm/test.sh" | netcat 89.196.167.2 4567
and let's say it return a string like, for example "Hello...bla".
(on the 89.196.167.2 i have made a server that takes ssh comands and executes them and returns the result to the client, and it is running ok, it return what i need, so this is not the problem)
I want to put this returned value, "Hello...bla",
Before I ran the script I have entered
# export CPIC_MAX_CONV=500
The following is the test1.script file
#!/bin/bash
function cpic () {
var="`export | grep -i "CPIC_MAX_CONV" | awk '/CPIC_MAX_CONV/ { print $NF } '`"
[[ $var=="" ]] && (echo "Empty String <<")
[[ $var!="" ]] && (echo "$CPIC_MAX_CONV")
echo "$var" ;
}
cpic
The output is:
# test1.script ---- Me
Is there any way to have an echo at the end of a pipe simply append to the current output rather than removing it all?
if i want to display "aaa" on screen:
(1)$: echo aaa | cat ... works OK
(2)$: echo aaa | ( cat ) ... works OK
(3)$: echo aaa | ( cat & ) ... NOT working
(4)$: ( echo aaa & ) | cat ... works OK
(5)$: echo aaa | ( cat <&0 & ) ... works ok in BASH (but not in SH)
(6)$: echo aaa | ( cat <&3 & ) 3<&0 ...
I have an echo statement in my script as below:
echo -ne "Check Script";
I was expecting it to print
Check Script
but I am getting the below output
-ne Check Script
But when I run the same script on some other machine I get the expected output.
What could be machine specific variables or properties because of which the script is behaving differently.
It is very interesting that if you intend to display like "0_1" with bash using the code
x=0
y=1
echo "$x_$y"
then it will only display
1
I tried echo "$x\_$y" and it doesn't work.
So my question is how to echo the form $x_$y ? I'm going to use it on a file name string.
I came across and unexpected behavior with redirections in tcsh.
I searched SO and found that to uppercase a string following would work
str="Some string"
echo ${str^^}
But I tried to do a similar thing on a command-line argument, which gave me the following error
Tried
## Output
echo ${1^^} ## line 3: ${1^^}: bad substitution
echo {$1^^} ## No error, but output was still smaller case i.e.
A recent test I took had a question on the output of the following bash command:
var=; [ -n $var ]; echo $?; [ -z $var ]; echo $?
The results are 0 and 0, indicating the return codes for both unary operators had no errors. This means $var resolves to both null (empty) and 'non-null' (not empty), correct?
How is this possible?