B Chen
B Chen

Reputation: 923

need to find the path for my file (cygwin in Window7)

My apology for the "newbie trouble" that I created for myself & apology for my poor command of computer lingo

I am running a Windows 7 laptop and have a big text file (~4Gb) that I need to find certain string.

Most programs in Windows 7 cannot handle the task (file too big to open in any program in the Microsoft suite), so I downloaded cygwin and tried to grep the specific string.

The problem is

(a) the 4 Gb file is stored in the desktop of my non-admin account.

(b) I assume cygwin runs in the admin account (although I use the desktop cygwin icon to launch the environment). The reason being that under cygwin, I see the handle A@Admin-THINK (running it on a Lenovo Thinkpad laptop)

grep the file of interest results in "No such file or directory"

I tried to find the path of the file (readlink, realpath) but guess the commands were not applicable here?

Also tried /home/A/file or /home/A/desktop/file but it is clear that my random guess fails.

From windows, the file should be in

C:/Users/non_admin/desktop/folder/file

What would be the right path of the file to grep the string using cygwin ?

Upvotes: 0

Views: 221

Answers (2)

Jon
Jon

Reputation: 3671

You can use /cygdrive to access the Windows filesystem. In your case, try

 grep foo /cygdrive/c/Users/non_admin/Desktop/folder/file

Upvotes: 1

Doug Henderson
Doug Henderson

Reputation: 898

From windows, you can get the correct file path from the context menu item Copy as path into the copy/paste buffer.

In Cygwin mintty, use

FilePath=<paste>

where <paste> means to use paste from mintty's context menu to make a variable with the value of that path.

Then use

grep <string> $(cygpath -u "$FilePath")

to search the file. The "'s are in case the file name contains spaces.

HTH

Upvotes: 0

Related Questions