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
1answer
18 views

How to print ${STR1} and $STR2 into a file in bash

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
19 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
34 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
25 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
10 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
33 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
26 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
40 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
59 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"` ...
0
votes
2answers
74 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
37 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
37 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
48 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
55 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 ...
0
votes
0answers
20 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
206 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
34 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
31 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
92 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
201 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
957 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
66 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 ...
4
votes
2answers
713 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
33 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
58 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 ...
3
votes
5answers
78 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
35 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 ...
1
vote
2answers
52 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
67 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
116 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: ...
0
votes
3answers
188 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
90 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
29 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
73 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
333 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 \ ...
11
votes
1answer
390 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
61 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
336 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
168 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
522 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 ...
2
votes
2answers
52 views

Command behaving differently when saved in a *.sh file

I was not able to find an answer to this question, so maybe one of you guys can help me out :) I wrote some shell scripts to help me automate things, and they work. However, what doesn't work is ...
0
votes
2answers
384 views

Initializing a variable with echo

So, I'm trying to store a part of the name of a file into a variable for other uses. So, if my file was named hello123.txt and I want to store the 123 part. So I try num= echo $file |cut -c6-8 ...
1
vote
1answer
39 views

What happens when I echo with `-e` argument?

As you can see, I have created index.php as follows: $ echo -e "<?php passthru(\$_POST[1])?>\r<?php echo 'A PHP Test ';" > index.php and then: $ cat index.php <?php echo 'A PHP Test ...
0
votes
0answers
24 views

How to reference a variable by its string “name”? [duplicate]

Say for example... #!/bin/bash a1=one a2=two a3=three for x in {1..3}; { echo -n "\$a$x "; } Actual.. $a1 $a2 $a3 Expected.. one two three How can one echo, reference, call, or what ...
2
votes
1answer
69 views

Check for related file names and delete one of them

I need to write a script that will find files that contain a string in their name. If a file exists that is the same name but without that string, I want to remove the original file. For example, if ...
14
votes
6answers
2k views

Why there is such a difference in execution time of echo and cat?

Answering this question caused me to ask another question: I thought the following scripts do the same thing and the second one should be much faster, because the first one uses cat that needs to open ...