What's the deal with Deno? We talk with a major contributor to find out. Listen now.

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1
vote
3answers
110 views

How to edit a text file without a text editor?

I found myself in a situation, where I needed to connect to a remote machine there were no text editors installed (no vi or nano). The only way to edit text files is to use echo and cat. Can you ...
2
votes
2answers
91 views

How to expand “word” in bash? Not talking about file wildcards

Sorry for so simple question, but I could not find a solution myself. I run: $ echo {1..4} 1 2 3 4 And that's OK to me. But if I: $ echo "{1..4}" > file $ cat file {1..4} $ echo $(<...
0
votes
1answer
479 views

echo strings but extra question mark was added to the output

Strange "?" got added to the filename output. SCRIPTS="/path_to_script/" SUMMER=`cat /path_to_file/summer.txt` for i in ${SUMMER}; do cat <<- EOF > $SCRIPTS/20190430_$(echo ${i})_step4.r #...
1
vote
2answers
81 views

How to echo content into a series of new file generated by cat

I would like to write a loop to generate 22 R scripts with contents generated in echo. What went wrong in this loop that I could not get the 22 files with the corresponding content? I tested echo "i ...
15
votes
6answers
6k 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 ...
0
votes
1answer
8k 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 ...
1
vote
1answer
484 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.
33
votes
6answers
9k views

Is 'cat' a shell built-in or an external program?

When I use the type command to find out if cat is a shell built-in or an external program I get the output below: -$ type cat cat is hashed (/bin/cat) -$ Does this mean that cat is an external ...
4
votes
1answer
266 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....
4
votes
4answers
4k views

echo a file as a single line with \n's

I have a multi line text file that I want to echo out as a single line file where the new lines are shown as \n. Any pointers would be great.
5
votes
2answers
9k views

Difference between 'cat < file.txt' and 'echo < file.txt' [duplicate]

I have a file named file.txt which has some content say 'abcdef', when I do cat < file.txt I get the output abcdef but when I do echo < file.txt, no output is returned. Why doesn't the input ...
1
vote
1answer
2k views

echo for Print output

I want to use the echo command to show this output: 10 item in File but seems that the below command does not work: echo "$('cat file.txt | wc -l ') items in File"
1
vote
1answer
598 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 ...
1
vote
1answer
899 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 '...
2
votes
2answers
1k 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 ...
21
votes
2answers
24k views

Unexpected results testing serial loopback using echo and cat

So I have a standard RS232 serial port that is looped back to itself by simply running a wire from Tx to Rx. I'm testing loopback by running echo and cat in two separate terminals: cat /dev/ttyS1 ...
30
votes
1answer
24k 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 but ...