The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
1answer
32 views

./a.out && echo $? only prints return value if return = 0

echo $? in the following scenario does not display the return value, i.e. 1. echo "int main() { return 1; }" > foo.c gcc foo.c && ./a.out && echo $? However, echo $? works when ...
10
votes
6answers
936 views

What is the reverse of echo -e?

If I have a string with nonprintable characters, new lines, or tabs, is there a way I can use echo to print this string and show codes for these characters (e.g., \n for new line, \b for backspace)?
4
votes
3answers
103 views

How do I capture stdin to a variable without stripping any trailing newlines?

In a shell script... How do I capture stdin to a variable without stripping any trailing newlines? Right now I have tried: var=`cat` var=`tee` var=$(tee) In all cases $var will not have the ...
6
votes
2answers
173 views

echo of a string with an exclamation point

Here are what I put in bash and the results I got about 'echo': $ echo '!$' !$ $ echo "!$" echo "'!$'" '!$' I'd like to know how 'echo' deals with the second input. It seems to me that ...
14
votes
3answers
1k views

why 'echo --help' doesn't give me help page of echo?

I tried 'man echo' in Bash and it told me that 'echo --help' will display help then exit, and similarly, that 'echo --version' will output version and exit. But why it doesn't work ? 'echo --help' ...
9
votes
3answers
553 views

Why does “wc -c” print a value of one more with echo?

When running echo abcd | wc -c it returns 5. But the word abcd is only 4 characters long. Is echo printing some special character after the word abcd? And can I prevent echo from printing that? ...
1
vote
5answers
76 views

How to overwrite stdout using echo? [closed]

We know to overwrite bar.txt, we can use this: echo "foo" > bar.txt but how can we overwrite to the standard output? I tried this command: echo "foo" > but it failed. I want this because ...
2
votes
2answers
49 views

Read Multiple Entries from an Input File

I wrote a program in Fortran that asks me for latitude and longitude and the name of the output file every time I run it. It works great. What I have been meaning to do is run this program for the ...
3
votes
2answers
172 views

How do I echo an expression with both single and double quotes?

I have tried many things, but I'm new to the shell. Is it possible to have both double and single quotes within an echo? I want to generate echo "scan 'LPV',{FILTER => "(PrefixFilter ...
3
votes
3answers
172 views

Split a returned block of text into lines in terminal?

When I give commands like echo $PATH or which program, I often get a very large block of text consisting of may directories. This is fairly useless, if I am for example, looking to see if there is or ...
3
votes
1answer
248 views

Prevent hanging of “echo STRING > fifo” when nothing is reading that FIFO

When I echo something to a named pipe made with mkfifo, it hangs if no process is reading from that pipe. How can I prevent that, i.e., stop that from hanging? And by the way, why is that hanging ...
83
votes
3answers
8k views

Why is “echo” so much faster than “touch”?

I'm trying to update the timestamp to the current time on all of the xml files in my directory (recursively). I'm using Mac OSX 10.8.5. On about 300,000 files, the following echo command takes 10 ...
4
votes
4answers
519 views

Bash Scripting : Printing column data in the same row

I have written a bash script to calculate the size of a PostgreSQL database and print the output along with the date when the script was executed in a text file. The script code is as follows: ...
0
votes
1answer
164 views

How to display data in columns in two variables with the same format?

I coded the following to display data formatted in columns: str1='hello i am robert and your ma frnd' str2='thisisaverylongword thisistoohehehe andherefinishthe string hereis a other ...
7
votes
3answers
491 views

What defines the maximum size for a command single argument?

I was under the impression that the maximum length of a single argument was not the problem here so much as the total size of the overall argument array plus the size of the environment, which is ...
0
votes
3answers
243 views

echo bytes to a file

I'm trying to connect my rasberry Pi to some display using the i2c bus. To get started I wanted to manually write stuff, bytes in particular to a file. How do you write specific bytes to a file? I ...
3
votes
2answers
97 views

Command in variable one are affecting output of other variable when displayed together in UNIX

I am having two file naming Extra_info and Class_info Class_info contains data : stuId stuName stuClass S01 jagdeep First S02 harsh First S03 Roop Second S04 Kali Third ...
6
votes
3answers
400 views

adding an empty first line inside csv file

I input data into a csv by 'echo'-ing some values into another csv. I tried echo "" and in the next line echo "values" but i get intermittent empty lines.. I need empty line only at the start....
1
vote
3answers
76 views

Print a message from the left-hand side of a pipe

I want to use a variable from the main shell in a sub shell. I did: export mysql_root_password="test" ( echo $mysql_root_password ) | dialog --gauge "Working hard..." 6 50 But it does not ...
3
votes
0answers
173 views

How to create a bash command which creates output that exactly mimics a source text file that can be pasted into bash shell where histexpand is on?

The goal is to create a bash one line command that can be copied and pasted - for instance published on a web forum - and then patches files. See it as a way to distribute a patch file by copy and ...
4
votes
2answers
569 views

print command instead of echo in linux

I simply can print a message in terminal using linux echo command. prayag@prayag$ echo "prayag works on JVM" prayag works on JVM Can I have the same output with print command. I actually went ...
6
votes
4answers
689 views

What is the difference between echo `date`, echo “`date`”, and echo '`date`'?

What is the difference between these three commands? echo `date` echo "`date`" echo '`date`' I am confused on what the differences actually are. I think that when the ' are around it means that it ...
2
votes
1answer
336 views

How to echo in shell script without executing the result

I am using this code to print all open files in the specified changelist. while read line; do echo "$line" done < `p4 opened -c $changelist` However, the line also gets executed and I get ...
1
vote
3answers
63 views

return the numeric value of a indexed variable rather than its name [duplicate]

The following piece of code illustrates my problem I'm afraid I oversimplified it way too much in the first round. #!/bin/bash dogLover=1 catLover=2 for ii in dog cat do ...
1
vote
3answers
250 views

Is there any alternative to echo daemon to display ip?

Is there any alternative to echo daemon to display ip instead of given string? For ex: my ip = 80.1.2.3 server ip = 1.2.3.4 root@my-machine bash$ telnet 1.2.3.4 Trying 1.2.3.4... Connected to ...
2
votes
1answer
84 views

How to use OSLEC with Alsa as default, not with Pulseaudio or other thirdparty package involved?

Oslec Echo canceller I have seen some packages used OSLEC and there echo cancle was very well. So for a test simulation, how could i install the OSLEC only with Alsa (i do not use PulseAudio at all, ...
7
votes
7answers
2k views

timestamp before an echo

Exists a nicer way to create timestamp in front of an echo? Currently I do it this way: #!/bin/sh if mount | grep -q /mnt/usb; then echo `date +%R\ ` "usb device already mounted" else ...
6
votes
3answers
3k views

Escape sequences with “echo -e” in different shells

I just noticed that it seems like the flag -e does not exist for the echo command in my shell on Linux. Is this just a messed up setting or is it "normal"? Some code as an example: #!/bin/sh echo -e ...
1
vote
2answers
2k views

Print line numbers of files I am searching through [closed]

I am looking for a way to print the line number of files my script is going through. I have found $LINENO but when I do echo 'Found foo in file' $(basename $foo) 'on line' $LINENO >> foo.csv ...
5
votes
2answers
603 views

Unix: how to read line's original content from file

I have a data file, the content is as follows: department: customer service section: A department: marketing section: A department: finance section: A When I read each line, I ...
1
vote
2answers
178 views

Why the inconsistency with using cat vs. echo piped to this sed command?

Inspired by this question: sed: N command does not read single line I wanted to understand why there appears to be an inconsistency between the following 2 commands: #1. echo This command produces ...
3
votes
4answers
160 views

How can I print “-n” with `echo`?

I feel really stupid, yet I can't figure how to print the string "-n" with the over 30 years-old command echo. I tried these: Michaels:Scripts$ echo -n Michaels:Scripts$ echo "-n" Michaels:Scripts$ ...
3
votes
2answers
263 views

insert text in a file using echo command [duplicate]

I am trying to insert some text in a file in the following way sudo echo "abc-abc/abc/abc" >> /etc/portage/make.conf but it give me the error Permission denied although I am using sudo ...
4
votes
1answer
207 views

Ubuntu unattended install : echo keypress to dialog

Ubuntu 12.04 LTS Server 64 My unattended-mode bootstrap.sh script contains: apt-get upgrade -y I know that during execution a primitive UI for GRUB installation will be shown which requires ...
1
vote
1answer
217 views

Cannot echo colored text when inserting in status bar in dwm

I'm using Fedora 18. I'm trying to create a custom status bar in dwm. Now what I'm thinking of is to check if the battery is under a certain level, the background of the battery region in the status ...
2
votes
1answer
83 views

'echo' eats part of the message

I want to write a script that will dump all partitions of my android device through the android debug bridge and since this is a time intensive process I want to notify the user about the progress by ...
1
vote
2answers
1k views

using bash script to output new script: need mixture of variables to be replaced and not replaced

I'm having a problem with bash variable substitution. Here's a silly example of what I am trying to do. I need to output a new script from a bash script. A line (see echo in my example) has a mixture ...
5
votes
2answers
432 views

Quoted vs unquoted string expansion

for i in $(xrandr); do echo "$i" ; done for i in "$(xrandr)"; do echo "$i"; done for i in "$(xrandr)"; do echo $i; done I understand why 1 differs from 2. But why does 3 give a different output ...
0
votes
4answers
539 views

echo a loop with variables command

I have several lists and want to run some commands over them. As lists are long I want to run those commands parallel to each other, hence using nohup. For every item I tried to echo a loop that ...
-1
votes
1answer
58 views

How to get all Users and echo if they work or not?

How do I get a list of users(given from the command line) with grep and output if they are logged/work or not ?
1
vote
2answers
173 views

How to make sure the shell builtin echo is invoked so that its not visible in process list?

Is this going to be visible in the process listing if the below line is executed from a command line or a shell script bash -c "echo $password" or i just need to do echo $password from within ...
0
votes
2answers
100 views

Supress expansion of * in echo

I am working on a script which dynamically executes some queries on daily basis. These queries are coming from a table in the database. Here is the sample output of the query table: ...
0
votes
1answer
90 views

the use for echo without argument in shell scripting

I have a following bash script I encountered on the web that prints the power set of a given lines of elements. p() { [ $# -eq 0 ] && echo || (shift; p "$@") | while read r ; do echo ...
1
vote
1answer
2k views

How to put value of echo pipe netcat commands into variable [duplicate]

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 ...
3
votes
2answers
274 views

echo string >> file does not work

I wrote the following script: for filename in `find . -name '*'.cpp | grep $IN_REGEX | grep -v $OUT_REGEX` do echo "Output file is $OUTPUT_FILE" count=`git log --pretty=format: --name-only ...
137
votes
4answers
43k views

Why is printf better than echo?

I have heard that printf is better than echo and I can recall only one instance from my experience where I had to use printf because echo didn't work for feeding some text into some program on RHEL ...
2
votes
3answers
549 views

How to stop `grep` from truncating pipe output

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? For example, how can I keep the output for my cat and grep and add "END OF ...
-4
votes
2answers
3k views

Redirecting the content of a file to the command “echo”

I have a file named my_file.txt whose content is just the string Hello. How could I redirect its content to the command echo? I know I have the commands less, cat, more... but I need to do it with ...
8
votes
3answers
18k views

How do I set an environment variable on the command line and have it appear in commands?

If I run export TEST=foo echo $TEST It outputs foo. If I run TEST=foo echo $TEST It does not. How can I get this functionality without using export or a script?
2
votes
1answer
255 views

My echo command doesn't accept switches (echo -n or echo -e)

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 ...