echo

What are the differences in echo between zsh and bash?

余生长醉 提交于 2021-01-28 10:50:46
问题 In bash, in this specific case, echo behaves like so: $ bash -c 'echo "a\nb"' a\nb but in zsh the same thing turns out very differently...: $ zsh -c 'echo "a\nb"' a b and fwiw in fish, because I was curious: $ fish -c 'echo "a\nb"' a\nb I did realize that I can run: $ zsh -c 'echo -E "a\nb"' a\nb But now I am worried that I'm about to stumble into more gotchas on such a basic operation. (Thus my investigation into fish: if I'm going to have to make changes at such a low level for zsh, why not

turn on echo temporarily

六眼飞鱼酱① 提交于 2021-01-28 03:03:45
问题 I am creating a batch file and have turned echo off with @ECHO OFF however I need to demonstrate one of the commands in the batch onscreen how would I temporarily turn on ECHO 回答1: Syntax: ECHO [ON | OFF] ECHO [Message] A simple ECHO ON should solve this mystery. 来源: https://stackoverflow.com/questions/10036250/turn-on-echo-temporarily

Add line after matching a pattern [duplicate]

元气小坏坏 提交于 2021-01-27 14:09:48
问题 This question already has answers here : Using sed, Insert a line above or below the pattern? [duplicate] (4 answers) Closed 3 years ago . I have a file say test with following values Linux Solaris Fedora Ubuntu AIX HPUX How to add a line with system hostname after the line matching AIX? If I do echo `hostname` >> test system hostname comes at the last after HPUX. 回答1: With sed: sed "s/^AIX$/& $(hostname)/" file If the line could contain AIX : sed "s/AIX.*/& $(hostname)/" file Edit: To append

Why does python exit immediately when I pipe code in with echo but not with cat?

那年仲夏 提交于 2021-01-27 12:52:33
问题 #!/bin/bash echo "print('Hello 1')" | python3 cat | python3 -u <<EOF print('Hello 2') EOF echo "print('Hello 3')" | python3 This outputs Hello 1 Hello 2 It will wait for me to press enter before printing the final Hello 3 . It does this also using python's -u flag for unbuffered output. Why does it do this for cat but not for echo ? 回答1: You aren't using cat. You're using a here-doc, and cat is waiting for input separately. Just remove the cat | and try it again. echo "print('Hello 1')" |

echo to stdout and append to file

六眼飞鱼酱① 提交于 2021-01-27 05:49:58
问题 I have this: echo "all done creating tables" >> ${SUMAN_DEBUG_LOG_PATH} but that should only append to the file, not write to stdout. How can I write to stdout and append to a file in the same bash line? 回答1: Something like this? echo "all done creating tables" | tee -a "${SUMAN_DEBUG_LOG_PATH}" 回答2: Use the tee command $ echo hi | tee -a foo.txt hi $ cat foo.txt hi 回答3: Normally tee is used, however a version using just bash: #!/bin/bash function mytee (){ fn=$1 shift IFS= read -r LINE

PHP while statement echoes duplicates

佐手、 提交于 2021-01-20 12:01:31
问题 I'm new to PHP and I have spent several hours researching and trying to figure out what I'm doing wrong. I'm joining several tables to populate a client profile page with multiple transactions from a transactions table. The rest of the page is working with the query as expected, but when using a while statement, each transaction in the result is repeating equal to the total number of transactions in the result. For instance, if the result has 3 transaction numbers (1, 2, 3), the while

Why is a PHP script waiting “to finish script” before any echo/output?

半城伤御伤魂 提交于 2021-01-19 01:30:27
问题 Considering a simple script <?php echo "hi"; foreach ($_GET['arr'] as $a) { echo $a ."<br>"; } echo "<p>Masel tov</p>"; foreach ($_GET['arr2'] as $a) { echo $a ."<br>"; } i expect the script to echo continuously. Instead the script does echo all-at-once when finished. Even the first " hi " gets echoed after 1 minute when the script finishes. Is there a setting to prevent this from happen or why is that so? 回答1: There is a function ob_implicit_flush that can be used to enable/disable automatic

Why is a PHP script waiting “to finish script” before any echo/output?

孤者浪人 提交于 2021-01-19 01:29:05
问题 Considering a simple script <?php echo "hi"; foreach ($_GET['arr'] as $a) { echo $a ."<br>"; } echo "<p>Masel tov</p>"; foreach ($_GET['arr2'] as $a) { echo $a ."<br>"; } i expect the script to echo continuously. Instead the script does echo all-at-once when finished. Even the first " hi " gets echoed after 1 minute when the script finishes. Is there a setting to prevent this from happen or why is that so? 回答1: There is a function ob_implicit_flush that can be used to enable/disable automatic

Docker COPY no such file or directory

浪尽此生 提交于 2021-01-07 10:50:42
问题 Building docker image fails on copy task. No such file or directory. I am using the hello world example from spring Building from openjdk:8-jdk-alpine Run echo ${PWD} prints / Run ls prints a set of normal directories (/usr /var etc) but no project files are present Why is docker not using the WORKING directory? FROM openjdk:8-jdk-alpine VOLUME /tmp ARG DEPENDENCY=target/dependency COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib COPY ${DEPENDENCY}/META-INF /app/META-INF COPY ${DEPENDENCY}/BOOT-INF

Docker COPY no such file or directory

假如想象 提交于 2021-01-07 10:47:31
问题 Building docker image fails on copy task. No such file or directory. I am using the hello world example from spring Building from openjdk:8-jdk-alpine Run echo ${PWD} prints / Run ls prints a set of normal directories (/usr /var etc) but no project files are present Why is docker not using the WORKING directory? FROM openjdk:8-jdk-alpine VOLUME /tmp ARG DEPENDENCY=target/dependency COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib COPY ${DEPENDENCY}/META-INF /app/META-INF COPY ${DEPENDENCY}/BOOT-INF