0

I have a shared folder in Windows which has a file. I want to write a shell script in Linux to open that file and manipulate it. Can that be done directly?

Here's what I have tried but it didn't work:

#!/bin/sh 

file="file:///\\Home\Folder\File.txt"

for i in `cat $file` 
do
echo $i 
done; 

I read somewhere that I first need to mount the Windows path, enter my username and password, then read the file. Is this the only way to do so?

Dr.Bake
  • 141
  • 4
  • 18
  • You could use [smbclient](https://www.samba.org/samba/docs/current/man-html/smbclient.1.html) to copy the file without mounting the remote fs, and then edit it and copy it back. But mounting is probably the most "direct" way. – Elliott Frisch Jan 31 '18 at 05:11
  • 1
    https://mywiki.wooledge.org/DontReadLinesWithFor and [use double quotes around any variable which contains a file name](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable) – tripleee Jan 31 '18 at 05:23

0 Answers0