bash - read command doesn't wait for input -


i have problem executing simple script in bash. script this:

#! /bin/sh  read -p 'press  [enter]  continue deleting line' sudo sed -ie '$d' /home/hpccuser/.profile 

and when execute script ./script output this:

press  [enter]  continue deleting line./script: 3: read: arg count [sudo] password user 

i run read command directly in terminal (copy , paste script terminal) , works fine; waits enter hit (just pause).

because script starts #!/bin/sh rather #!/bin/bash, aren't guaranteed have bash extensions (such read -p) available, , can rely on standards-compliant functionality.

see the relevant standards document list of functionality guaranteed present in read.

in case, you'd want 2 lines, 1 doing print, , other doing read:

printf 'press [enter] continue deleting...' read _ 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -