Questions about either the shell builtin or `/bin/echo`. This tag should not be used if your question is simply about printing to the terminal, only apply it if your question is specific to the `echo` command.

learn more… | top users | synonyms

0
votes
0answers
18 views

Echo variables sshpass [duplicate]

I want to do sshpass to a server to get lots of information from it. But as some logic will be involved, I tried to create a variable inside sshpass and echo to the client (first test). It is not ...
2
votes
1answer
35 views

Echo input text amount limit?

I'm trying to do echo "foo foo foo ....[many many lines of foo here] foo" > "/Users/myname/destination.txt" through Applescript, but it returns an error when the characters in the lines of foo ...
1
vote
1answer
37 views

Piping data to a fifo with EOFs every second

I'm trying to pipe some raw binary data through to a fifo (out.pipe), and ensure that EOFs get sent at regular intervals. I do not understand why the following line will not do what I want: while ...
0
votes
0answers
31 views

get user input in terms of size (GB or MB)

I created script to calculate shmmax shmall shmmini Total_Memory_M=$(dmidecode -t 17 | grep Size | awk '{print $2}' | grep -o '[0-9]\+' | paste -sd+ | bc) Total_Memory_G=$(echo $Total_Memory_M /1024 |...
0
votes
1answer
28 views

What is special about printf over echo

I was finding length of a variable as below: `set num=123456` `echo $num|wc -c` it returned output as 7 (suppose to return 6) I did same with printf `printf "%s" $num|wc -c` it returned output ...
0
votes
1answer
22 views

How to print ${STR1} and $STR2 - not their contents - into a file?

I need to print expressions ${STR1} and $STR2 into a file -- not the content of the variables. How can I accomplish this using echo or printf?
0
votes
0answers
29 views

Cannot telnet outside network to open port on OEL 6 machine

I have an OEL 6 server that locally is assigned IP 10.200.15.79. It is hosting a business application that uses port 1031 to send and receive information through TCP/IP. To allow this on the OEL ...
1
vote
2answers
37 views

Get the output in a formatted way

In a for loop, I am using the command: echo " Job_time is $i : Stopping the job " Sample output: Job_time is 6 : Stopping the job Job_time is 6.50 : Stopping the job Desired output: Job_time is ...
0
votes
1answer
32 views

How to rewrite `install -T /dev/null xxx`

I am trying to write in one command the following 2 ones: install -m 0755 -T /dev/null filename echo "file content" > filename Is that possible? Is there any way to avoid the -T /dev/null for "...
0
votes
0answers
11 views

running command in Mobax Terminal are there plugins that are needed

while read CTFlist; do #next we need to create ctfs padded with zeros as a variable ctfPadded=$(printf ${ctflist}00000000) #then call rc2 key as variable rc2Key="TemporaryRC2Key1" #next create a ...
2
votes
2answers
34 views

Get specific result from function

Is there a way to return a specific value in an echoing function? return allows me to return an exit status for the function. I need to return a more sophisticated data structure such as an array, or ...
0
votes
1answer
30 views

Why does Grave operator changes output format of the command? [duplicate]

Hello i want to ask why when i write ls -l there is new line after every row but when i assign it to a variable myVariable=`ls -l` and than echo that variable echo $myVariable i get ...
0
votes
0answers
19 views

check if a variable contains letters and exit if true [duplicate]

I am using the line below to verify that an argument do not have a letter. If it have, the script will exit. Can you help me on how I can exit the script if the argument have a letter? echo $1 | ...
-1
votes
1answer
36 views

Can I use echo to run other commands using this method? [closed]

I'm still learning unix and I need to know if there is a way to perform the following actions. Is there any way I can echo a read variable, and in the process, dissect it letter by letter, and assign ...
0
votes
1answer
45 views

Shell script that outputs chmod command for all files

On my EC2 Linux server, I blindly ran chmod 777 at directory that it turns out I should not have. There are hundreds of files in there, and I'm not sure which ones need to go back to their original ...
-1
votes
3answers
86 views

Why am I getting an error “print_unicode: line 9: printf: missing unicode digit for \u Unicode 0187” with this script

I have written them following shell script to view what the Unicode characters look like on my terminal. #!/bin/bash X=0 while [ $X -lt 65536 ]; do HEX=`bc <<< "obase=16; $X"` HEX="...
1
vote
2answers
91 views

format command output with variable and fixed space

How can I achieve this best maintaining the hierarchy on the left and aligning the size value on the right? Also, at the same time I'd like to round the size to one or two digits. I tried with printf ...
0
votes
1answer
45 views

Why does print work with awk but echo doesn't?

To sum it up.... This works: awk 'BEGIN { FS=":"; } { print $1 $3 $5; }' /etc/passwd But this doesn't: awk 'BEGIN { FS=":"; } { echo $1 $3 $5; }' /etc/passwd Being fairly new to learning ...
0
votes
1answer
40 views

Echo to file clashes with mailutils

After installing ssmtp and mailutils, writing to a file with 'echo' tries to send me an email to username@hostname. For example: Sending mail with mailutils: echo "Body text here." | mail -s "...
0
votes
2answers
55 views

using sed to modify all files in a directory and name the outputs accordingly

I want the sed command to work on all files in a directory and output the result into a new file. If f is val1.txt, the name of the output file should be val1_ended.txt -this is what I am trying to do ...
1
vote
0answers
59 views

BASH dd problem

i am trying to learn bash and now im trying to do a script for burning isos. I made the number "4" command to make sure the variables were right. the message i get when i complete my program and ...
1
vote
0answers
21 views

What does echo *? [duplicate]

Recently I was writing a bash-script and added a line: $ echo * and got an output of file names and directory names. What is the context of this list (just out of curiosity)?
1
vote
1answer
38 views

Looking for an external command that can do the same thing as echo

echo is bash builtin. Is there an external command which can do the same thing as echo? (may do more)
4
votes
2answers
230 views

How do I decode a list of base64-encoded file names?

I have a list of base64-encoded file names in the pattern of {base64-encoded part here}_2015-11-12.pdf. I'm trying to decode that list of files and return it on the command line as another list, ...
1
vote
1answer
38 views

trap echo does print not write to console when writing to file

When I terminate "CTRL+C" the following script #!/bin/bash function waa(){ for i in {1..10} do echo "start.sh: sleeping $i" sleep 1s done } trap "echo 'GAGA'" TERM waa >&...
0
votes
2answers
32 views

echoing a variable inside a variable

In my environment, the following variable is set: X=/home so echo $X gives me /home Now I set Y=$X echo $Y gives me $X. If I want to get /home using Y is it possible?
1
vote
1answer
117 views

Is it possible to do a here-document in one line or echo verbatim?

I often find myself testing out a command (e.g. cat file | awk 'stuff') in the shell and when I'm satisfied with the way it works, I append the command to a script file. Let's say this is the command ...
1
vote
1answer
261 views

Get absolute path of file OS X

I am creating a script which will prompt the user to enter a location of file and it will convert it to an absolute path. This is what I have so far. I'm not sure how to append these together. ...
12
votes
4answers
1k views

Why doesn't echo called as /bin/sh -c echo foo output anything?

For example, while this works: $ echo foo foo This doesn't: $ /bin/sh -c echo foo Whereas this does: $ /bin/sh -c 'echo foo; echo bar' foo bar Is there an explanation?
2
votes
1answer
71 views

Run executable with variable in Bash

I have the following simple script to run an executable: ./executable.x -input input.dat << i input1 input2 i This works perfectly and all is right with the world. However, I would like to ...
5
votes
2answers
861 views

What does “echo (ls)” do in bash?

When I run echo (ls) in bash it returns: -bash: syntax error near unexpected token `ls' I understand that I should escape parenthesis or quote to get plain text output. But the result still does ...
0
votes
1answer
41 views

Whatis command (shell builtin vs executable programs)

I know that whatis command is used to output a brief description about an executable program (Command). So both whatis cd whatis type Will print: nothing appropriate (Because from my ...
0
votes
1answer
66 views

how to send data from serial port to printer?

I have a telephone system that is connected to my old Ubuntu machine and is receiving SMDR data from it. Connected to dev/lp0 is a dot matrix printer, phone system connected to /dev/ttyS0 Currently I ...
4
votes
5answers
85 views

How to print out “-E” in bash echo?

I want to execute echo and get an output like: $ export EVAR="-E" $ echo "$EVAR" -E I have stored "-E" in a bash variable, say $EVAR. If I execute echo $EVAR, echo will print out nothing. Perhaps ...
3
votes
0answers
38 views

Why only 4 chars get sent to serial port via command-line

I'm trying to communicate with NodeMCU (CP210x USB/UART) from command-line. However it does not respond to my commands. I have set the correct baudrate via stty 9600 raw. echo "gpio.write(0,gpio.LOW)"...
1
vote
2answers
53 views

Appending Echo [Password Generator]

I am creating a password generator however I am not get the passwords to append properly. Here is my script i="0" while [ $i -lt 5 ] do echo -n '#' >> passwords.txt && openssl rand ...
2
votes
1answer
71 views

Run a command stored in a variable to echo into a file

How can I get the stored command to work for the following scenario: CMD='echo "test" >> test.txt' $CMD It will work for other scenarios like: CMD='mkdir test' $CMD
-1
votes
2answers
185 views

Nested echo command in backticks

I want to know why an extra echo will print in my shell. I'm using bash version 4.2.46(1). echo `echo `echo $SHELL`` A interesting issue is if I replace '``' with $() it doesn't print extra echo: ...
-1
votes
1answer
23 views

Help with permissions

I am trying to set up permissions, but I don't know what exactly, as a user. Could anyone tell me which permission will allow me to execute the touch and echo commands in a directory?
0
votes
3answers
197 views

What do the `echo $?` and `ls >> $File 2>&1` commands do?

Can someone help me with understanding this. echo $? -- I know it outputs a variable of some kind... and this ls >> $File 2>&1 ---- can someone explain what this does?
1
vote
2answers
91 views

Escape characters from echo -e

I have the following in my .bashrc file I use for a log: function log(){ RED="\e[0;31m" RESET="\e[0m" echo -e "${RED}$(date)" "${RESET}$*" >> "$HOME"/mylog.txt } But when I do ...
-5
votes
1answer
32 views

question related to variable assignment in unix [closed]

Having: TIMESTAMP="date +%Y.%m.%d.%T" When I enter $TIMESTAMP on console it gives me the correct result: ~$ $TIMESTAMP 2015.11.30.15:32:39 however when I do echo $TIMESTAMP I am not getting the ...
0
votes
2answers
31 views

How do I include commands in an echo statement?

Pretty simple, but I didn't find a question on here that asked this exactly. I thought this would work but it does not. echo "Your disk usage is ${df -k -h}." How do I make the above work?
0
votes
0answers
89 views

Difference between two almost same command

Please consider two following command: $ echo ls | xargs -I cmd echo cmd | source /dev/stdin $ echo ls | source /dev/stdin What's the difference between these commands? In my machine the result of ...
2
votes
5answers
348 views

Combination generator with memory and resource management

I have this bash script, which is generating every single combination of arrays in 5 digit long: #!/usr/bin/env bash for combo in \ {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,...
11
votes
1answer
392 views

Why is echo matching some files twice?

$ touch file{1..12} $ echo *e{1..12} file1 file2 file3 file4 file5 file6 file7 file8 file9 file10 file11 file12 $ echo *{1..12} file1 file11 file12 file2 file3 file4 file5 file6 file7 file8 file9 ...
2
votes
1answer
69 views

Debian 8 - problem with no echo in programs

I have a problem, because some programs and functions are not working like in Debian 7. For example: reboot are not sending broadcast message, service [something] [start|stop] not echoing anything, ...
1
vote
3answers
377 views

How to make the shell execute only external echo, not the builtin one?

I have a C program which uses system() library function. Below is the source code. #include<stdlib.h> int main() { //Some code system("echo Hello World"); //some code return 0; ...
-1
votes
1answer
204 views

how to use ECHO to print out the du of a home directory in mb?

This should be a simple hw problem but I can't seem to get it to work correctly. This is an old lab that I missed a while ago (make ups are not allowed), so no I'm not just trying to get other people ...
3
votes
3answers
642 views

How do I use a multi-character delimiter for array expansion in bash?

I'm reducing the question to (I believe) the simplest case. Let's say I have a script myscript.sh with the following contents: #!/bin/bash IFS='%20' echo "$*" If I run the command as follows, the ...