Tuesday, May 7, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 946  / 2 Years ago, fri, october 28, 2022, 3:04:45

We can open a parent folder of any file using nautilus script like



#!/bin/bash 

nautilus "$1"


If I do this script on symbolic link which is on the ~/Desktop, then it will open the Desktop itself.



How can I recode this script to open the parent of actual file symbolic link is bound to? For example, if I have a sym link file Desktop/my-doc.doc linking to the doc file located in /media/myharddisk/my-doc.doc, the script will open /media/myharddisk/ and NOT ~/Desktop in Nautilus.


More From » nautilus

 Answers
2

Try this:



#!/bin/bash

file="$(readlink -f "$1")"
nautilus "${file%/*}"

[#27271] Saturday, October 29, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ightrushi

Total Points: 129
Total Questions: 125
Total Answers: 127

Location: French Southern and Antarctic Lands
Member since Fri, Jan 6, 2023
1 Year ago
;