Linked Questions

70
votes
1answer
20k views

Why eval the output of ssh-agent?

In order to run ssh-agent I have to use eval $(ssh-agent) Why do I have to eval the output of ssh-agent? Why isn't it designed so that I can just run it? Note: Backticks (`) removed as they are ...
28
votes
3answers
10k views

Do functions run as subprocesses in Bash?

In Advanced Bash-Scripting Guide, in example 27-4, 7-th line from the bottom, I've read this: A function runs as a sub-process. I did a test in Bash, and it seems that the above statement is wrong....
14
votes
3answers
8k views

How can I work with binary in bash, to copy bytes verbatim without any conversion?

I am ambitiously trying to translate a c++ code into bash for a myriad of reasons. This code reads and manipulates a file type specific to my sub-field that is written and structured completely in ...
18
votes
3answers
20k views

What is $() in a command?

What is $() in Linux Shell Commands? For example: chmod 777 $(pwd)
8
votes
3answers
2k views

How to check if stdin is /dev/null from the shell?

On Linux, is there a way for a shell script to check if its standard input is redirected from the null device (1, 3) *, ideally without reading anything? The expected behavior would be: ./...
6
votes
1answer
2k views

I don't understand what a single backtick and double quote and >> do in this script

This example was in a Linux book: $ cat sort-wc #!/bin/bash # Sort files according to their line count for f do echo `wc -l <"$f» lines in $f done | sort -n $ ./sort-wc /etc/passwd /ect/fstab /...
4
votes
3answers
3k views

awk in ssh command line complains 'unexpected newline or end of string' How to resolve?

While running the below script had an issue, ^ unexpected newline or end of string How could I resolve this ? [root@emrbldbgdapd2 ~]# ./collectdata.sh collect the data of 10.209.61.124 awk: cmd. ...
1
vote
2answers
14k views

Current time/date as a variable in BASH and stopping a program with a script

I am trying to create a raspberry pi spy cam bug. I am trying to make it so the new file created for the various processes come up with NOW=`date '+%F_%H:%M:%S'`; which works fine. but it requires ...
0
votes
3answers
23k views

How to create user and password in one script for 100+ users

I have written a script for adding and setting password for 100+ users. Eg: for setting password of the user I want to set in "user+123" format for all the users I.e user will change according to the ...
8
votes
2answers
801 views

Which shells don't support dollar-parenthesis expansion, and demand backticks?

The modern recommendation is to use: $(...) instead of the older: `...` mainly for readability and to avoid the need for escaping when nesting. Which shells do not support the $(...) form, and ...
1
vote
3answers
6k views

grep a awk string from a file and write to the other part of string file

My file, aaa,has 5 lines. 01_AAA-11-ID22 02_BBB-33-ID44 03_CCC-55-ID66 . . I tried to grep anything after underline from a file bigfile.txt for i in $(cat aaa) do A= $(awk -F '_' '{print $1}' $i) B=...
0
votes
2answers
2k views

getting unexpected EOF error

I am getting the following error /tmp/filechecking.sh: line 11: warning: here-document at line 6 delimited by end-of-file (wanted `EOF') /tmp/filechecking.sh: command substitution: line 8: unexpected ...
-3
votes
4answers
8k views

-eq: unary operator expected [closed]

x=$? if [ ${x} -eq '0' ]; then echo "something missing" exit 1 else echo "all present" fi Why I am getting -eq: unary operator expected when executing above? A more complete version of what I am ...
5
votes
1answer
756 views

Can someone explain the strange behavior of backslash in command substitution?

I have found that in bash echo `echo \\` output \ \ but echo `echo \\ ` outputs nothing
-2
votes
1answer
3k views

wc -c not working in a loop in the script [duplicate]

So I'm writing a simple script that checks if the size of the file is less than the given argument and if its true then its suppose to echo "YES" #!bin/bash Function () { cd $1 lista=`ls` ...

15 30 50 per page