The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
2answers
39 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
160 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
156 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
218 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 ...
82
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
426 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
113 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
404 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
203 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
90 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
324 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
74 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
166 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 ...
3
votes
2answers
484 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
544 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
310 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
243 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
78 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
1k 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
2k 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
443 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
168 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
150 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
224 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
200 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
201 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
76 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 ...
0
votes
1answer
876 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
388 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
475 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
167 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
95 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
84 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
262 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 ...
129
votes
4answers
40k 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
521 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 ...
7
votes
3answers
16k 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
234 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 ...
3
votes
1answer
486 views

Printing colored text using script

When I type below command in the shell I get the OUTPUT in green color. Command echo "\033[32mCONNECTING TO abpwrk\033[m"; Output(in green color) CONNECTING TO abpwrk But if I use the same ...
4
votes
2answers
296 views

Why am I observing different behaviour of echo?

I am a bash beginner and observed the below behavior of echo #!/bin/bash x=" hello" echo $x echo "$x" Now when I run the above code I get ronnie@ronnie:~$ bash test.sh hello hello ...
7
votes
1answer
780 views

Append same text to many files using cat or echo?

How can I write the same content to many text files by using cat or echo in only one command? For example I want to write "hello" to file1 and file2. I tried: echo "hello" >> file1 file2 ...
5
votes
3answers
567 views

Construct a command by putting a string into a tty

I managed to do this echo -n "command" > /dev/tty1 The letters appear, and the cursor moves, but they are "ghosts" - if you hit enter, nothing happens (they are not in stdin). Edit: In the ...
23
votes
1answer
977 views

Why does echo >file use more real time than echo | sed >file?

The example, below, surprised me. It seems to be counter intuitive... aside from the fact that there is a whisker more user time for the echo | sed combo. Why is echo using so much sys time when it ...
9
votes
2answers
1k views

Using sed to color the output from a command on solaris

I have a ksh script that must work on both linux and solaris. I'm trying to color the output of specific commands. It works on linux (specifically RHEL6), but not on solaris (SunOS 5.10). Command ...
7
votes
4answers
12k views

printing colored text using echo

I know that for printing a colored text using echo, for example red color, the code is: echo -e "\e[1;31m This is red text \e[0m" and I know that in this example, 31 is code of red color and the ...