2009-06-13 4 views
9

¿Es posible utilizar la herramienta "diff" sin tener archivos físicos? Algo como esto:Dif sin archivos

diff "hello" "hell" 

Respuesta

16

Puede diff entrada estándar con un archivo utilizando el nombre de archivo especial -:

# diff the contents of the file 'some-file' with the string "foobar" 
echo foobar | diff - some-file 

Con fiesta, también se puede utilizar canalizaciones con nombre anónimos (un nombre poco apropiado) a diferencia de dos tuberías:

# diff the string "foo" with the string "baz" 
diff <(echo foo) <(echo baz) 

Ver también How can you diff two pipelines with bash?.

+0

++ Dale un golpe. – guns