Skip to main content

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.

Filter by
Sorted by
Tagged with
4 votes
3 answers
135 views

Echo asterisk for password shell inputs

We can use the command stty -echo with a bash shell script to prevent characters to be echoed to the console, e.g., for password input. Is there a way to print a * for each input character instead, ...
Luis A. Florit's user avatar
2 votes
4 answers
332 views

output of a command framed by a couple of '#' characters

I want to be greeted by # ##################################################### # ### PostgreSQL 16.3 ################################# # ##################################################### on ...
vrms's user avatar
  • 161
0 votes
2 answers
432 views

Reducing microphone noise using pipewire modules

With pulseaudio, it was easy to load a module for microphone noise reduction. This link explains it clearly: https://askubuntu.com/questions/18958/realtime-noise-removal-with-pulseaudio I want to add ...
floupinette's user avatar
-1 votes
1 answer
46 views

BASH SCRIPT: Echo to file is transfered to remote host [closed]

I am writing a bash script in order to perform some automatic backups to a remote storage server. The batch script will be run with cron jobs however I'm testing it before. See script below: #!/bin/...
Frangu Mădălin's user avatar
1 vote
6 answers
149 views

bash-as-sh echo -n

Is there a way to get bash (version 3.2.57(1), if it matters), in the mode where it's emulating sh, to implement the -n option to the echo builtin? Specifically, I'm curious whether there might be one ...
Steve Summit's user avatar
0 votes
0 answers
32 views

How to resolve the issue of the echo (with >>) eating up the line indendations? [duplicate]

Consider the below commands typed into the terminal: $ ls my-file.js prefix.yml $ cat prefix.yml apiVersion: v1 kind: ConfigMap metadata: name: file1-cm namespace: default data: my-file.js: | $...
deostroll's user avatar
  • 317
0 votes
1 answer
145 views

How to make crontab interact with session of currently logged-in user?

THE PROBLEM Crontab does work - but just aside, not in interaction with users. How to make crontab talk to currently logged-in user by automatically perceivable prompt output? For example, a wake-up ...
futurewave's user avatar
-1 votes
1 answer
76 views

Checking if I'm correct about the order of operations in Bash

Guten Tag! I'm a rookie in everything Bash-related. I'm familiarizing with the syntax and wanted to know if the order of operations in this command is as I thought or not. The command: echo 2 * 3 > ...
elkronequis's user avatar
0 votes
0 answers
35 views

What is the difference between three `echo` commands? [duplicate]

What are the differences between the three following echo commands? var='You' echo "Hello\nThere\n${var}" Output: Hello\nThere\nYou echo 'Hello\nThere\n${var}' Output: Hello\nThere\n${...
Fred's user avatar
  • 335
2 votes
1 answer
145 views

Print Variable containing backslashes

I have something like this: A=$(curl https://mysite.com) and the curl request returns the string \"Hello World\". When I now want to print A to the console using one of: echo "$A" ...
Cake's user avatar
  • 31
-1 votes
1 answer
101 views

The Command tput sgr0 Changes my Terminal Font and Text Colour, how to Stop This? Any echo After tput sgr0 Outputs as Bold White

When I do tput sgr0 it changes my terminal font and colour to white (should be black) and looks blocky. Please see screenshot: How do I stop this? To be more concise, any echo after tput sgr 0 seems ...
Nickotine's user avatar
  • 489
0 votes
1 answer
99 views

How to read files of kind "-diary.txt-" using echo?

I have a file named "-diary.txt-", I need to get it's content. When trying to read it using echo < "-diary.txt-", it returns a blank string. I did some research, and came up ...
Nikita Re's user avatar
0 votes
1 answer
243 views

Why does this "-e" option for echo get written to a file (although not enclosed in double quotes)? [duplicate]

#!/usr/bin/env python3 from subprocess import run from sys import modules def main(): doas() def doas(): ch = input("Ready to proceed with setting up doas?[Y/n]?") if ch == 'y': ...
John Smith's user avatar
0 votes
1 answer
111 views

Flush output continuously with xargs

The function output the size of the downloaded file and the speed of transfer separated with newline. Example: 20 #<< data 3.0M #<< speed 25 1.2M Now, it goes like this: output_data_func |...
decipher's user avatar
  • 312
0 votes
0 answers
34 views

printf and echo -n Work Differently - Why? [duplicate]

echo -n my_function() { echo -n "$@" } my_function hello world I get my desired output: hello world printf my_function() { printf "$@" } my_function hello world I get only ...
Bog's user avatar
  • 1,034
1 vote
1 answer
32 views

Concatenating string passed into a control sequence

I have this echo invocation that prints a blue bar in a Bash terminal: echo $'\e[48;2;0;0;255m \e[0m' I would like to pass some variables to it, something like (this doesn't work): ...
user73235's user avatar
0 votes
1 answer
102 views

Does the echo command create a swap file when it writes a line to a file?

I am currently working on a personal project, and I would like to simply record logs in the following way using the echo command. My question is if the echo command accesses the same file at the same ...
JongSun Park's user avatar
0 votes
2 answers
191 views

Why is echo "\*" the same as echo "\\*"

Title. echo "\*" has the exact same output as echo "\\*", \*. I am using GNU bash 5.2.15. I expected echo "\\*" to output \*, but I do not know why echo "\*" ...
Christopher Lee's user avatar
0 votes
1 answer
30 views

extract last part of filename using echo - having assigned variables using wildcards

I am trying to extract parts of a filename, where I want to extract everything after the first _ and I have found a working solution, see below file=22NGS71294_S191_R1_001.fastq.gz echo $file ...
ch_esr's user avatar
  • 3
1 vote
1 answer
31 views

watch -n1 $() does not run $() every interval

watch -n1 $() does not update $(). what is the workaround? here is my example: watch -n1 echo $(( $(date +%s -d "sun") - $( date +%s ) )) this results in Every 1.0s: echo 106602 ...
stacking and exchanging woohoo's user avatar
1 vote
1 answer
155 views

Why I can pipe echo into bc, but I can't do the same with printf?

I can pipe echo into bc. But I cannot do the same with "printf": it gives syntax error. ❯ echo "100-5" | bc 95 ❯ printf "%s" "100-5" | bc (standard_in) 1: ...
robertspierre's user avatar
0 votes
3 answers
594 views

What does echo $$ do? [duplicate]

I was messing around with echo and was trying stuff like echo ~. When I was trying to use $ to substitute environment variables I accidentally tried echo $$. Surprisingly instead of an empty line I ...
nded23959's user avatar
0 votes
1 answer
38 views

Some dump comes out when giving inputs to program by using a pipe in Linux

I'm now trying to do exploitation by using a race condition bug. However, a problem occurs; Values that I have never given to the process come out. Below is a description of the case. Scenario: An ...
toubva's user avatar
  • 1
0 votes
0 answers
84 views

echo incorrectly interpreting colors

I want my terminal prompt to change color depending on success of the previous command. Currently I achieve this with the following script: exitstatus() { if [[ $? == 0 ]]; then echo -e &...
Trashbin2019np's user avatar
11 votes
3 answers
3k views

Temporarily unset bash option -x

I like to use set -x in scripts to show what's going on, especially if the script is going to run in a CI/CD pipeline and I might need to debug some failure post-hoc. One annoyance with doing this is ...
Ken Williams's user avatar
0 votes
1 answer
132 views

What are the types of echo output (Opaque, Semi-Opaque, Clear text) [closed]

I have an assignment from my lecturer to Write a script that will show each of the 3 types of echo (opaque, semi-opaque, and cleartext) The issue is, I don't know what the types are. I have searched ...
caged_raven_wings's user avatar
0 votes
2 answers
43 views

Echo message when flag is detected

This works well at running Seamonkey only once per 24 hours. I would like to show a message if the flag is detected. I am not sure where to put that echo statement. #!/bin/bash # # Run this script ...
fixit7's user avatar
  • 139
0 votes
1 answer
36 views

Echo'ing the variable muliple times while reading the variable values from a file

I am trying to write a bash script which would read values from a file and echo out the values. But for what ever reason it is not working correctly. My first file is having the below values Alts Risk ...
ranjit abraham's user avatar
3 votes
2 answers
2k views

How can I write in multiple files at once using 'cat'?

This question is kind of related to my previous question. This is the output of tree: [xyz@localhost Semester1]$ tree . ├── Eng │   ├── credits │   ├── links │   └── notes ├── IT │   ├── credits │   ├─...
Random Person's user avatar
0 votes
4 answers
729 views

Read from file; and execute its content line by line; terminate at first error [closed]

I am reading the content of a file do.sh using the bash command line structure. I want to execute each line of this file, line by line, so that, later, I can add some text to the script which can ...
Amit Kr. Ratewal's user avatar
4 votes
2 answers
655 views

How to print a double quote in POSIX scripting?

So far, I've been using "\"" to print a double quote: $ x="abc def" $ echo "x=\"$x\"" x="abc def" However, it seems like that behavior is ...
finefoot's user avatar
  • 3,142
1 vote
0 answers
164 views

How to export a variable and log the details to the console at the same time?

How to export a variable and log the details at the same time? For example, how to do the following in a one liner? export myvar=$var1$var2$var3 echo $myvar
phanin's user avatar
  • 119
2 votes
2 answers
3k views

Fastest way to write bash variable to a file

I want to generate some big files for some experiment. This is my script. It creates a file then reads it to a variable and then tries to write it as many times defined in the loop in files: #! /usr/...
DEKKER's user avatar
  • 968
0 votes
1 answer
1k views

can 'cat' command be a pipe target?

I used to do bash programming long, long time ago but over a period of time I moved onto other programming languages. My work demands I look into a bash script and I found this piece of code which I ...
stirfries's user avatar
  • 103
1 vote
2 answers
398 views

zsh: alias or shell function to only echo its command line, including shell control characters

Using zsh, I'd like to create an alias or a shell function that operates as follows: I want this alias or shell function to echo its command line without honoring any shell control characters such as &...
HippoMan's user avatar
  • 657
3 votes
2 answers
1k views

file listing: difference between ls and echo *

on a lustre file system with thousands of file in directories, each time I type ls I get a large delay until files are listed. Same happens with other commands that need file listing. But if I type ...
xaratustra's user avatar
0 votes
1 answer
140 views

echo >>regular_file vs echo >>&fd: one closes, other does not

In my observation, echo to regular file echo >>regular_file opens the file, appends to it, and then closes the file. Whereas echo to an open file descriptor echo >>&fd* doesn't close ...
codepoet's user avatar
  • 596
1 vote
1 answer
524 views

Why is it recommended to use "printf -- <arguments>" instead of "echo <arguments>?" [duplicate]

In the Bash Pitfalls on "Greg's Wiki" I found the following quote: In fact, the echo command cannot be used with absolute safety here. If the variable contains -n for example, echo will ...
Sante Kyaku's user avatar
0 votes
1 answer
43 views

I am trying to understand what a particular echo statement does

I am trying to understand what the second echo statement does exactly (it's an existing script).. echo "Triggering report.. " curl -s -X POST "http://aaa.bbb" echo -e \ '\ ' I ...
Teddy's user avatar
  • 103
2 votes
1 answer
896 views

How to display echo messages from a systemd-timer script in journalctl?

I run via a systemd timer a shell script that starts some programs (they display some output) and uses echo to provide some feedback. root@srv ~ [127]# cat /etc/systemd/system/borg.timer [Unit] ...
WoJ's user avatar
  • 1,585
2 votes
3 answers
2k views

How to add echo write commands to sudoers

I would like to add a command that use echo to write to files into sudoers so that it can be run without a password. Typically the command would go like this: sudo sh -c 'echo 1 > /sys/devices/...
Cestarian's user avatar
  • 2,071
7 votes
2 answers
2k views

How to write binary values into a file in Bash instead of ASCII values

I am dealing with an embedded system which has some memory that is accessible by a file descriptor (I have no idea what am I saying, so please correct me if I am wrong). This memory is 32 kB and I ...
DEKKER's user avatar
  • 968
3 votes
3 answers
2k views

How to print to stdout after exec >/dev/null

In a script, I have a long list of commands that print to stdout. I want to hide all output. So instead of redirecting each command, I put exec >/dev/null at the beginning. What options do I have ...
finefoot's user avatar
  • 3,142
0 votes
0 answers
28 views

Why is my script misbehaving sometimes? [duplicate]

I have created a script that can split an audio file into smaller files via ffmpeg using timestamps, and another script which can take in timestamps & names in batches. My use for this script ...
Cestarian's user avatar
  • 2,071
2 votes
3 answers
3k views

Stuck at removing a trailing newline from a string variable

Sometimes simplest things take your time in shell scripting like crazy. Content='me \n you \n him \n' echo $Content > Names.txt When I open the Names.txt it has two empty lines at the end. I want ...
Saeed Neamati's user avatar
-1 votes
1 answer
917 views

Why is “echo $SHELL” not captured by remote SSH output?

When I capture the output of a remote SSH call using cat, whether in bash or in Python, things work as expected. E.g, this works just fine: import subprocess rc = subprocess.getoutput(“ssh user@host; ...
Scott Skiles's user avatar
0 votes
2 answers
718 views

How to correctly line break and concatenate a string in a bash script

I have a Bash script with a function to log messages with time and status, and I want to keep my script 80 column only: #!/bin/bash log_message() { echo "[$(date)]-[$1] : $2" >> log....
DEKKER's user avatar
  • 968
0 votes
0 answers
425 views

write terminal output to file while keeping new lines [duplicate]

when I call env to see the environment variables it shows nicely with new lines: $ env SHELL=/bin/sh EDITOR=vi PWD=/home/user ... but when I want to store this to a file the new lines get ...
DEKKER's user avatar
  • 968
0 votes
1 answer
611 views

Why is shell/terminal printing extra new line. What can be done to prevent it?

root@kali-linux:~# echo -ne "hi" hi root@kali-linux:~# echo "hi" hi root@kali-linux:~# I am using bash shell, xfce + i3wm + stterm in kali. On previous version of kali, there ...
Machinexa's user avatar
  • 123
0 votes
2 answers
2k views

Trying to create a while loop to output content of one file to another

I am trying to create a while loop so that it takes content from one file and creates some content on another file. But what i noticed is that it is only creating the last line of the file instead of ...
ranjit abraham's user avatar

1
2 3 4 5
11