Shorter awk
awk '{gsub(/\/,"/");print "smb:/" $0}'
Exemplo de saída:
$ printf "%s" '\MACHINE\dir1\dir2\file.xyz' | awk '{gsub(/\/,"/");print "smb:/" $0}'
smb://MACHINE/dir1/dir2/file.xyz
Java
Muito primitivo, use com cautela. Uso: java translatepath towin[tonix] "/path/to/file"["\path\to\file"]
public class translatepath
{
public static void main(String[] args)
{
System.out.println(args[1]);
if (args[0].contentEquals("tonix"))
{
System.out.println(toNixPath(args[1]));
}
else if (args[0].contentEquals("towin"))
{
System.out.println(toWinPath(args[1]));
}
}
public static String toNixPath(String path)
{
return path.replace("\","/");
}
public static String toWinPath(String path)
{
return path.replace("/","\");
}