Skip to content
Advertisement

Tag: echo

echo printing working directory files names for no reason

why echo printing the files names ? gives this output but running pacmd list-sinks | grep “index:” in the shell gives * index: 1 index: 2 index: 3 Answer pacmd returns * pattern. In for … in …; do … done loop, the list pattern contains * without any protection. So, bash replace * by all files found in current

reading and analyzing a text file with bash script

I want to read a log file and want to extract 5-6 number digit that is written right next after the keyword “salary”. And then want to analyze if the salary is above 2000. If there is even one above 2000, it is a MNC otherwise unknown. After writing the salary, the line ends mostly but sometimes there is an

How to print a string AFTER the date in Linux Terminal?

I want to type a one-line command in Linux that will print the date followed by a string to the Terminal. For example, “… is today’s date.” This is what I tried. However, this printed ” is today’s date. Sat Feb 20…” I thought reversing the order would help, but this only printed the date. Conversely, my third attempt only

how can i echo a line containing single quotes?

I want to echo a line containing single quotes but when I am echoing it, the output comes out without the quotes inside that line. I am using this echo rule_files: [ ‘${path.config}/folder/*.py’ ] and the output is rule_files: [ ${path.config}/folder/*.py ] I want the output to include the single quotes around the path. Answer You have to escape the

Why can’t I sudo echo a line in /etc/?

I am on centos and I did sudo echo ‘testline’>>/etc/test/test it said -bash: /etc/test/test: Permission denied However, when I do sudo vi /etc/test/test and insert testline and do :wq it writes out fine, why is this happening? Answer You need to wrap the whole statement (including the redirect) into a group so the sudo extends around it. Note: that, too,

Extra percent sign appears in echo bash

I’ve got the following script below which is supposed to demo CPU utilization: For some reason, when the percentage is echoed out, two percent signs appear instead of the last digit of the number and a percent sign. For example, the output is sometimes 2.7%% instead of 2.72%. Everything works fine when I take the percent sign away, but even

echo does not print a variable in bash

I’m facing a very strange issue. I have 2 files ber_log_before.txt and ber_log_after.txt. Their contents are ber_log_before.txt ber_log_after.txt There are $ it’s normal. Then I wrote a basic bash command to parse them Why 1st val 14 2em val 24 is not echoed??? If I replace by Then at least I have 2em val echoed. I guess that awk can

Undersired echo truncate in sh Linux

I want to send two variables as input to another command in shell script. I have tried many methods to send the two variables but I am getting unexpected problems with echo command. the above string gives unexpected truncated output.i am getting the Variables after reading from a file.(ex : HOURS1=cat time_now |cut -d ‘.’ -f 1 ) I have

Echo -e escape sequences?

After days of researching I still don’t understand why : gives me an output of : anb While I understand that echo -e activates the escape sequence , So it should work on the first example but it doesn’t .. I’m lost. I tried same commands in Ubuntu and OpenSuse .. both , same results . Any Help ? Answer

If a File is Empty, Write Text to First Line

I need to check to see if two files are empty. If they are, then write “-999” to the file, else run an average on the numbers within the file. Here is the coding I’ve been trying to use: Code: Contents of file_all: Answer the appropriate way to check whether a file is empty is using -s not -z (which

Advertisement