Tag Info

Hot answers tagged

4

You don't need the cat. sed happily accepts the file name as argument: sed 's/^ *//' <file> If you use GNU sed you can use the -i or --in-place switch to edit the file in place: sed -i 's/^ *//' <file> To answer the question, you can achieve “full file buffering” using the tool sponge from the moreutils package. Using sponge you can do: ...


4

Digging around here, I understood from http://unix.stackexchange.com/a/56877/54067 (where both the question and answer are worded differently and the problem is not related to interactive input) that the reason for the problem is that the cp -i expects the user to give the interactive input confirmation via stdin but in the cat | while read loop stdin is ...


4

Just use redirection operator > at the first line: sqlplus -s "/nolog" <<EOF >logfile conn / as sysdba @?/sqlpatch/19282021/postinstall.sql exit; EOF You can also write >logfile at the beginning of the line, what is equally legal syntax in most shells, but less commonly practiced. >logfile sqlplus -s "/nolog" <<EOF conn / as ...


2

From OpenSSH readpassphrase.c, line 75: /* * Read and write to /dev/tty if available. If not, read from * stdin and write to stderr unless a tty is required. */ The program reads and writes the TTY directly hence it's not possible to disable direct input by just closing the standard input and output pipes. You have to tell the SSH ...


2

Common mistake, wrong order of redirection, try this: … sendmail_alive.sh >/tmp/sendmail_alive.log 2>&1 It works like this: file descriptor stdout to /tmp/sendmail_alive.log file descriptor stderr to the value of stdout (/tmp/sendmail_alive.log) With your order, you first point the stderr where originally was stdout and you get the stderr ...


1

Linux specific: echo |perl -e '$p=getppid; `echo foo > /proc/$p/fd/2`' If you here redirect stderr 'foo' is still printed on the terminal: echo |perl -e '$p=getppid; `echo foo > /proc/$p/fd/2`' 2>/dev/null


1

Store the output of smartctl into a variable and use it as many times as you like. smartctl_output=$(smartctl -a /dev/sda) serial_number=$(printf %s "$smartctl_output" | awk 'sub(/^Serial Number: */,"")') printf %s "$smartctl_output" >"$serial_number.txt"


1

You could use another command (namely lsblk) to get only the serial number of that particular device (so no need to parse smartctl output): smartctl -a /dev/sdb > $(lsblk --nodeps -no serial /dev/sdb)


1

For now find . -name '*.php' -exec iconv -f CP1251 -t UTF-8 {} -o {} \; works like a charm



Only top voted, non community-wiki answers of a minimum length are eligible