I'm looking at some old shell scripts and there is a line that I don't quite understand:
~]$ sftp -b /dev/fd/3 [email protected]
I can see from the man file that -b is for batch, and that the argument is supposed to be a batchfile.
In this case, it looks like the batch file is supposed to be on a /dev/fd/3 - a floppy drive ? I can't seem to get to it.
Any ideas what this is supposed to do ?
The "/dev/fd*"
files are special devices. These aren't really taking up that much space on your system. They allow a process to access file descriptors by number; 0,1,2
are standard input
, standard output
and standard error
, and other open files start with 3
In your case sftp
using -b
to read command from /dev/fd/3
Example:
[root@04 fd]# exec 3< /etc/resolv.conf
[root@04 fd]# cat /dev/fd/3
search example.com
nameserver 10.10.10.10
nameserver 20.20.20.20
You can read data using read
command
[root@04 fd]# read -u 3 a b
[root@04 fd]# echo $a $b
nameserver 10.10.10.10
output of /dev/fd
directoy
[root@04 fd]# ls -l /dev/fd/
total 0
lrwx------ 1 root root 64 Feb 20 14:34 0 -> /dev/pts/0
lrwx------ 1 root root 64 Feb 20 14:34 1 -> /dev/pts/0
lrwx------ 1 root root 64 Feb 20 14:34 2 -> /dev/pts/0
lr-x------ 1 root root 64 Feb 20 14:34 3 -> /etc/resolv.conf
Notes: In your case that input file could be different
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With