Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [echo]

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.

-4
votes
0answers
28 views

what is the difference between reading a file using cat vs echo [on hold]

how does the terminal handle a file when you run it through cat and echo: example how does it read, cat file | foo vs echo file | foo, do different processes open and read them, does the foo command ...
-2
votes
4answers
80 views

How should I use quoting with echo in Puppet?

I'm trying to use echo inside a Puppet rule to add a line to .bashrc, but I can't seem to get the quoting right. '/usr/bin/echo -E PS1=\"[\t--------------------------------------------------------\n-\...
3
votes
3answers
533 views

Xargs to extract filename

I would like to find all the .html files in a folder and append [file](./file.html) to another file called index.md. I tried the following command: ls | awk "/\.html$/" | xargs -0 -I @@ -L 1 sh -c '...
0
votes
2answers
38 views

Ansible: return status of the last task

I'm using this command to have a return from tasks in ansible. To see if they are successful or not. This is a example of my code in a playbook: - name: Install JDK8 shell: cd /tmp/install/ &&...
2
votes
1answer
55 views

Shell command executed differently in a terminal and script

The following sequence of commands ch=`echo "b_d" | sed 's/_/\\\\\\\\_/'` echo $ch when executed in a terminal or via source give an output b\\_d When ran as a scipt sh script.sh where the ...
0
votes
1answer
26 views

Echo a line of code to a file end up incomplete

While executing a script in bash echo "export PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '" >> /home/testusername/.bash_profile While I am reading the file is missing one character which is a "\" ...
-1
votes
1answer
140 views

Why does echo <<EOF … EOF not work [duplicate]

Just wondering if anyone can explain why this works: echo `cat <<EOF {"branch":"foo","value":"bar"} EOF` but this doesn't: echo <<EOF {"branch":"foo","value":"bar"} EOF (the second ...
0
votes
4answers
54 views

How to compare lines in a single file line by line and append the output to the same file

I have a file abc.csv that has the below contents. a6caa290d03ae75dd5f3bf9214f0b523;CO.jar,a6caa290d03ae75dd5f3bf9214f0b523;CO.jar, a1a5bf1547f50feea4120290343f89e4;Common.jar,...
1
vote
2answers
55 views

Add Two Spaces in a variable

I need to add two consecutive spaces to a variable. for e.g I want to write Feb 5 (with two spaces in-between) in a variable. I am using the following command but I get Feb 5 instead. I am using AIX....
2
votes
2answers
65 views

bash echo the command line executed at the command line itself (not in a script)

For documentation purposes, I mean to redirect to file stdout and stderr from a command I execute. For instance, I would run (my command is less trivial than the alias ll but it probably doesn't ...
0
votes
2answers
40 views

Why are spaces echoing as newlines?

I've got this JSON data that looks like this: [ { "loginId": "7638749", "customerprofileDetails": { "securityQuestions": [ "What is your favorite sports team?", "What ...
2
votes
3answers
72 views

why piping pwd and echo does not work? [duplicate]

I'm new to unix. I typed this command in ubuntu terminal: pwd | echo I expected to see the output of pwd in terminal(/home/fatemeh/Documents/Code/test) but the output was just a single empty line. ...
0
votes
3answers
73 views

Echo Permission Denied (Trying to use echo instead of ls command in shell script)

I am trying to write a script and at some point i needed to list all the things in a directory and grep someting from that directory. I can't do it with ls. ls is not my guy to do it. So i tried to do ...
3
votes
1answer
29 views

appending a line to a file if absent

I'd like to add a series of commands to a Makefile that append config lines when they are not already present. I've done this in the past in a manner like so: grep -vq "keyword" /a/b/c.conf &&...
-3
votes
1answer
36 views

Printf appending fails

I Tried to run the following similar commands in CentOS (12.x): printf "\nhello" "$HOME"/.bashrc printf "\nhello" ${HOME}/.bashrc After execution I display the content of the .bashrc file and see ...
13
votes
4answers
911 views

Is it possible to print the content of the content of a variable with shell script? (indirect referencing)

Let's suppose I've declared the following variables: $ var='$test' $ test="my string" If I print their contents I see the following: $ echo $var $test $ echo $test my string I'd like to find a ...
-1
votes
1answer
38 views

What does command “echo run -d” do?

I was going through some scripts in my organisation, and I'm wondering what echo run -d does. Note: The script was used to execute a jar file with some arguments.
1
vote
2answers
155 views

How to append multiple lines before the last line using echo command

{ This is test1 this is test2 this is test3 } Now i want append multiple lines before the last line using echo command Anyone please help me!!!! My output is look like below { ...
1
vote
2answers
156 views

Compare two variables with a Shell script

I am new to shell programming, please forgive any blunder. I've been unable to find an answer to this: I have a script that allows me to compare these variables: FT_NBR1=\'?"\"'\ FT_NBR2=rcrdmddd ...
1
vote
1answer
86 views

SSH remote - display echo on local terminal

The following is a part of my script where I want to echo some text to the local terminal if the condition fails in ssh. /usr/bin/sshpass -p $PASSWORD /usr/bin/ssh -t -o "StrictHostKeyChecking no" ...
0
votes
4answers
57 views

echo append onto existing row, continue on the row

How can I append the string :/etc/simmmerin/bin/ into a file filename using echo command onto an existing row. Can't get it working. echo ":/etc/simmerin/bin/" >> filename It just appends in ...
2
votes
2answers
27 views

Converting stdout to raw-data not accepting multiple words using xargs and piping

First off I apologize for the title gore, I am struggling for a good way to summarize this issue. Anyway, I have been piping various things to functions using xargs and I am running into a weird ...
0
votes
1answer
97 views

Operation of ` with echo when trying to awk [duplicate]

How come echo `echo "foo"` works but echo `awk '{ print "foo" }'` doesn't?
11
votes
2answers
2k views

Is it dangerous to run echo without quotes?

I've seen couple of similar topics, but they are referring to not quoting variables, which I know could lead to unwanted results. I saw this code and was wondering would if it be possible to inject ...
-1
votes
2answers
75 views

How to give inputs to the .sh in command line [closed]

I have script abc.sh and it shows 4 options to user & 1 we need to choose. at first we give inputs as 1 -for the first option Now again it will show me 3 options and I have to choose as 1 -for ...
0
votes
2answers
44 views

Basic doubt in echo statement

I have just started learning unix and came across very basic doubt in command line arguments. Suppose if in my script i do: echo $@ #Now this prints all the command line arguments args=$@ #Args ...
0
votes
2answers
1k views

using echo command with $ in shell script

Recently, i used echo command prefixing it with $. To my surprise what it resulted was an error. My command was something like this. # !/bin/bash $(echo 'a') The error was.. ./test1.sh: line 3: a: ...
0
votes
3answers
57 views

Escaping ; () in echo

how could i escaping ; or () or "" in echo ? I want to echo this command "LOAD DATA INPATH '$i' INTO TABLE transient.url_log_201803 partition (ds='$TGLS', periode='$WKTS');" but it says, syntax ...
0
votes
2answers
71 views

Printing variable doesn't print \ | / -

I am capturing Kafka startup script output into variable and while starting Kafka prints \ | / - to simulate spinning line. So when I do: res=`./confluent start kafka` echo $res The result is: ...
1
vote
2answers
175 views

I am trying to send stdout message to mailx — Red Hat

All, thanks for your help... This should be easy: My script prints this to stdout/terminal perfectly... its pretty in the script but not below... ???? : # Print to stdout echo "------- CAPACITY TEST ...
-1
votes
2answers
131 views

Backslashing does not work to send a bell via the echo command

The echo command doesn't want to interpret backlash escapes (with -e option attached). For example, I want it to ring a bell with: echo -e \a Nothing happens, except it prints: a or \a How to turn ...
0
votes
1answer
40 views

want to store date output in variable [duplicate]

i tried the below code to store the date output in variable. read -p 'date: ' mydate date_month= date -d "$mydate" +%b echo $date_month it is not printing the output. how to store the date output in ...
0
votes
1answer
126 views

Piping cat into wall (e.g. cat | wall)

Why does echo foo | wall work but cat | wall not work? In the latter case, I enter a couple lines into cat, and in theory they should pipe to wall; however, nothing happens.
2
votes
4answers
93 views

Ignore spacing between echo strings

I use echo to print two strings into a file in either of these two commands: echo -e "\n""x" >> ~/file echo -e "\n" "x" >> ~/file The first result is: x The second result is: x I ...
1
vote
1answer
24 views

variable name contains a variable inside it [duplicate]

I am trying to echo some values using a for loop. hwEventType.txt contains this : 11000 11002 11004 11006 13025 13026 Code : for event in $(cat /path/hwEventType.txt) do eval miny_"$event"_2001=`...
3
votes
1answer
140 views

What do special characters stand for in echo {A..z}

I know we can print a sequence of letters of the Alphabet using echo command and experimented it a little by doing this. Lowercase letter Sequence $ echo {a..z} a b c d e f g h i j k l m n o p q r s ...
4
votes
1answer
392 views

Point of the semicolon in this shellshock attack

I was reviewing a shellshock attack and didn't understand this piece of code: curl -v http://localhost/cgi-bin/shellshock.cgi -H "custom:() { ignored; }; echo Content-Type: text/html; echo ; /bin/...
-3
votes
2answers
543 views

echo curl stdout into crontab

This is my crontab pattern I store in my Github account: source ~/.profile 0 0 * * * # More cron commands As an exercise I tried to pipe the stdout data of curl into my crontab (I've changed Github ...
0
votes
2answers
66 views

Trying to echo a string will multiple spaces to a terminal but need one string as-is

trying to do the following: echo "- - 830 "FTL MFG" -" the "FTL MFG" should be left alone as one entry. what am I doing wrong?
-2
votes
1answer
52 views

Shortening a read operation

This is my current read operation that works okay but I'd like to shorten: echo "Please save your DB root password:" && read -s dbrp echo "Please save your DB user password:" && read -...
4
votes
1answer
207 views

Why does bash replaces text from command substitution with text thereafter

I was trying to parse some nginx config λ tree sites-enabled/ sites-available/ sites-enabled/ ├── bank.cwrcoding.com.conf ├── calendar.cwrcoding.com.conf ├── cloud.cwrcoding.com.conf ├── cwrcoding....
0
votes
2answers
164 views

echo a string with a string inside of it

I have a text file containing this: Hello \"${USER}\"! Today you drank ${COFFEE_COUNT} coffees. See you tomorrow! Now I have a bash script running that has these strings assigned (and exported). But ...
0
votes
2answers
116 views

Echo something to console each time you quit crontab

To edit the root crontab in Debian I do for example sudo crontab -e. To exit from the preferred text editor (Nano), I do CTLR+X. So far so good, but what if I want that each time I exit crontab, a ...
1
vote
3answers
128 views

pages of pdf file into variable

I have a problem with putting output of following instructions (instruction works) into variable: pdftk file.pdf dump_data | grep NumberOfPages | awk '{print $2}' when I do for example: VARIABLE=$( ...
1
vote
1answer
278 views

linux + how to use the tput bold in echo command

we have the follwing array - list1 and list2 list1="node23 node76 node 34" list2="node02 node2 node9 node21" we want to bold the list2 so list1 will printed without bold and list2 with bold example ...
0
votes
2answers
661 views

linux + print the values in the same line

when we print the variable data_data_dir , we get: echo $data_data_dir sdb sdc sdd sde sdf but when we print it with the following approach the we get the value not in the same line echo "[`date +%...
7
votes
1answer
92 views

Why does `md5sum` not give the same hash as the Internet does?

I want to find the md5 hash of the string "a", but running echo "a" | md5sum gives me another hash than what I get if I search the internet (for example using DuckDuckGo or the first search result I ...
7
votes
6answers
4k views

append text with echo without new line

I want to append text to file like echo "abc" >>file.txt. But this add abc after new line How can I add abc in the end of file with echo without new line?
1
vote
0answers
42 views

ssmtp myaddress@gmail.com < file.log doesn't work. Body is blank

I'm running a simple rsync script where I log stdout and stderr to two different files, rsync_stdout.log and rsync_stderr.log. When I'm trying to email the content of rsync_stderr.log using: echo $(...
1
vote
1answer
128 views

echo $HISTSIZE not printing when executed via shell script but works in command line

I created a shell script file named 1.sh with only one echo command: echo $HISTSIZE I made the file 1.sh executable and tried to run the file in the terminal by running the command ./1.sh It ...