how to know the device on which the file is located


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to know the device on which the file is located
# 1  
Old 09-08-2008
how to know the device on which the file is located

Hi,

i want to know on which device a file is located
is there any command or anyway to know it

thanks
santosh
# 2  
Old 09-08-2008
You mean you are given a file name and then you need to know the path to the file and then find the device the filesystem containing the file? Where are we starting? Exactly.
# 3  
Old 09-08-2008
yes, i will be knowing the filename.. i need to know the device the filesystem containing the file
# 4  
Old 09-08-2008
The df command coincidentally resolves the file name you give to it to the mount point and file system.
# 5  
Old 09-08-2008
So you do not know the path. df <path> will display the filesystem
Let's start with this
Code:
find / -name file.name -type f |\
while read fs junk
do
    path=$(dirname $file)
    grep "^$path"  /etc/mnttab
done

This will work if /etc/mnttab exists on your machine Otherwise we need the OS.
# 6  
Old 09-08-2008
era - I think the OP wants the device name. The standard for df is to show the filesystem - not the device.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in appending text to a file located in remote server

ssh -q "server_name sudo echo 'dbagroup::1234' >> sudo /etc/group"if i execute the above code its not getting appended. my requirement is to login to remote server and append dbagroup::1234 in /etc/group i am able to achieve this with tee -a command want to know why its not working with >>... (5 Replies)
Discussion started by: chidori
5 Replies

2. UNIX for Dummies Questions & Answers

sudo dmidecode where is the file located ?

Been through all my /sys /sbin /bin directories and can't seem to find it. (2 Replies)
Discussion started by: jcnewton13
2 Replies

3. Shell Programming and Scripting

Need help to change the content for remote located file

Hi All, I have a file that sits on 4 diffrent servers, those servers are diffrent region based and they are authentication protected and that file has a diff port numbers, so when run the script it must ask my login details,region of server and port no for that file once it took from me it... (1 Reply)
Discussion started by: tmarjuna
1 Replies

4. UNIX for Advanced & Expert Users

Need help to change the content for remote located file

Hi All, I have one file that sits on 4 diffrent servers, those servers are diffrent region based and they are authentication protected and that file has a diff port numbers, so when run the script it must ask my login details,region of server and port no for that file once it took from me... (1 Reply)
Discussion started by: tmarjuna
1 Replies

5. Shell Programming and Scripting

How do I go about finding a value located in one file in another?

Hi, I have to determine which VALID users made a failed loggon attempts on our server.To make a long story short, I have isolated the list of all the usernames and number of attempts in one file, and have isolated the valid users who have made failed loggon attempts in another file. I now have... (2 Replies)
Discussion started by: mojoman
2 Replies

6. Shell Programming and Scripting

use awk to read randomly located columns in an excel file

Hi, I have an excel file that have a random count of columns/fields and what im trying to do is to only retrieve all the rows under 2 specific field headers. I can use the usually command for awk which is awk 'print{ $1 $2}' > output.txt, but the location of the 2 specific field headers is... (9 Replies)
Discussion started by: mdap
9 Replies

7. Shell Programming and Scripting

Deleting a file located on another server

Hi, I have successfully copied a file from one server to another using following command. user1@server1# scp test.jsp user2@server2:/home/ Now i want to delete that copied file(test.jsp) from "server2" by running some command from server1. Please help... (2 Replies)
Discussion started by: SanketJOSHI
2 Replies

8. UNIX for Dummies Questions & Answers

Deleting a file located on another server

Hi, I have successfully copied a file from one server to another using following command. user1@server1# scp test.jsp user2@server2:/home/ Now i want to delete that copied file(test.jsp) from "server2" by running some command from server1. Please help... (1 Reply)
Discussion started by: SanketJOSHI
1 Replies

9. Shell Programming and Scripting

Pls Help - Need to edit file located in several directories

I need to update an entry called "mail.RiskNavigatorFromEmailAddress" in all of the "Application.properties" files below, which are located in several different directories... Each of these Application.properties files has the following entry: ... (3 Replies)
Discussion started by: kthatch
3 Replies

10. Solaris

Where Xorg X-Lock file is located in Solaris?

I am using Xorg server with Solaris 10. After unnormal poweroff dtlogin tells: "The X-server can not be started on display :0" I am absolutelly sure it is because there is still a X-lock file from the previouse X-session somewhere, but I do not know where is it located in Solaris! :confused: (2 Replies)
Discussion started by: eugrus
2 Replies
Login or Register to Ask a Question