Linked Questions

77 votes
6 answers
195k views

What is the difference between the printf function in bash and the echo function? Specifically, running: echo "blah" >/dev/udp/localhost/8125 did not send the "blah" command to the server ...
Kevin Burke's user avatar
  • 2,091
2 votes
1 answer
5k views

I have a script that is going to be executed by sh and bash on Debian Linux. When it is called by sh, the following echo command works perfectly, and replaces \t with 3 spaces. However, it fails when ...
Pravin.2087's user avatar
1 vote
1 answer
690 views

In the Bash Pitfalls on "Greg's Wiki" I found the following quote: In fact, the echo command cannot be used with absolute safety here. If the variable contains -n for example, echo will ...
Sante Kyaku's user avatar
0 votes
1 answer
685 views

The following script can only print -m but it can't print -n. #!/bin/sh echo $@ $ sh test.sh -m -m $ sh test.sh -n $
haolee's user avatar
  • 103
0 votes
1 answer
419 views

#!/usr/bin/env python3 from subprocess import run from sys import modules def main(): doas() def doas(): ch = input("Ready to proceed with setting up doas?[Y/n]?") if ch == 'y': ...
John Smith's user avatar
0 votes
0 answers
82 views

I would like to store an HTTP request in a variable and then use it with OpenSSL I now have HTTP_REQUEST="HEAD / HTTP/1.1\\nHost: ${HOST_HEADER}\\nUser-Agent: check_ssl_cert/${VERSION}\\nConnection: ...
Matteo's user avatar
  • 10.1k
0 votes
0 answers
41 views

echo -n my_function() { echo -n "$@" } my_function hello world I get my desired output: hello world printf my_function() { printf "$@" } my_function hello world I get only ...
Bog's user avatar
  • 1,154
0 votes
0 answers
38 views

i have a simple shell script that echoes variable in a file but i have issues getting it work the same way between the different distributions. The script #!/bin/sh res="=1B,\=AB=D2=DB=B5=A6e=FCj=...
Miro Igov's user avatar
0 votes
0 answers
26 views

I have a string S, for which I want to replace every b character with \\ (two forward slashes). So this is what I have: $ S="abc" $ A=$(echo $S | sed 's/b/\\\\/') In bash I get the expected ...
Good Guava's user avatar
847 votes
5 answers
394k views

I have seen -- used in the compgen command. For example: compgen -W "foo bar baz" -- b What is the meaning of the -- in there?
dogbane's user avatar
  • 30.8k
290 votes
21 answers
474k views

Using version control systems I get annoyed at the noise when the diff says No newline at end of file. So I was wondering: How to add a newline at the end of a file to get rid of those messages?
k0pernikus's user avatar
  • 16.7k
320 votes
12 answers
588k views

The following bash syntax verifies if param isn't empty: [[ ! -z $param ]] For example: param="" [[ ! -z $param ]] && echo "I am not zero" No output and its fine. But when param is ...
maihabunash's user avatar
  • 7,231
138 votes
20 answers
361k views

I was wondering how to count the number of a specific character in each line by some text processing utilities? For example, to count " in each line of the following text "hello!" Thank you! The ...
Tim's user avatar
  • 107k
90 votes
8 answers
137k views

I know that I could delete the last three chars with: echo -ne '\b\b\b' But how can I delete a full line? I mean I don't want to use: echo -ne '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\...
LanceBaynes's user avatar
  • 41.6k
63 votes
20 answers
44k views

I am trying to write a bash shell function that will allow me to remove duplicate copies of directories from my PATH environment variable. I was told that it is possible to achieve this with a one ...
Johnny Williem's user avatar

15 30 50 per page
1
2 3 4 5
27