Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [directory]

A file system structure in which to store computer files.

0
votes
3answers
29 views

How to escape parenthesis in bash rmdir?

I have a directory that has a name like 10.2 (14C92) i want to remove using rmdir -rf (to include their content). I am very new to the linux command line so i do know how to pass a space with \ but I ...
3
votes
1answer
201 views

Recursive shell script to list files

I'm trying to write a shell script that lists certain types of files in a Directory (and sub-directories). I'm struggling with the recursive part. Here's what I have: #!/bin/sh #download dir ...
-2
votes
0answers
39 views

Files in /home disappeared after installing Packet Tracer [duplicate]

I was installing packet tracer on my kali machine and I extracted the packet tracer in/home and I was trying to install it in /home and suddenly I checked all the files in /home disappeared. I've ...
6
votes
5answers
639 views

How to delete all directories in a directory older than 2 weeks except the latest one that match a file pattern?

I have the following path: /dir1/dir2/ In this path I have the following directories containing various (not relevant) application detrius: follower1234 1-Dec-2018 follower3456 2-Dec-2018 ...
0
votes
1answer
76 views

A specific directory is completely invisible to “ls” and “ls -la”, but I can “cd” into it

This started happening out of the blue. Originally, I was able to "ls" my "Storage" folder and all 3 subdirectories were listed accordingly. ('Beta Profiles' 'OS Backups' 'Software') Starting ...
0
votes
2answers
34 views

Check if any file exist in a folder when traversing through it

I have this script: local_dir="/some/dir1/" cd $local_dir for i in *.* do # do something ........ # [...........] rm $i done It throws an error when the folder is empty. *:...
1
vote
1answer
19 views

Tool for creating and calling folder structure templates?

Is there a Linux utility for creating templates for directory structures, outside of the scripts packaged with a DE like Gnome or LXDE? (I run openbox and would like to avoid a DE at all costs) There ...
1
vote
2answers
33 views

How to create multiple directories in Ranger?

As in the equivalent of mkdir dir1 dir2 when running in bash. This creates two separate directories, dir1 and dir2. If you run :mkdir dir1 dir2 in ranger, it simply creates a directory called 'dir1 ...
2
votes
3answers
44 views

print all 3-character-sub-directories using shell script in AIX

In my system, there is a /Test directory under which many directories are available. I want to print all directories with 3-character-name, in AIX system. I got code for Gnu/Linux. find /test -...
1
vote
2answers
29 views

Calling dir names from a paramater list file

Wondering if there is a best way to call directory names and iterate as parameter from a list. Example cat /dropbox/script/DirList.txt DIR_A DIR_B DIR_C DIR_D /dropbox/dev/inbox/<DIR_A>/ *.*...
8
votes
3answers
632 views

Flattening directory hierarchy preserving directory names in new directory name

I basically want to go from this: . ├── Alan Walker │   ├── Different World │   │ ├── 01 Intro.mp3 │   │ ├── 02 Lost Control.mp3 │   │ └── cover.jpg │   └── Same World │   ├── 01 Intro.mp3 │...
0
votes
1answer
17 views

Nginx requires identical permissions for a whole path up to a directory “assets” of my app to be able to read and serve assets

I have a web app in the folder: /home/main_user/dir1/dir2/my_web_app/ In there I have an executable file and the folder assets. Nginx is setup this way - to serve assets only: location ~ ^/...
0
votes
2answers
54 views

Shorten very long dir name in bash prompt

How to get from this prompt ~/this/is/a-very-very-long-directory-name/dir to this ~/this/is/a-ver...name/dir in a bash prompt? So shorten directory names longer than nn (20+) characters to ...
0
votes
2answers
88 views

How do I make a file in a user's home directory uneditable to that user but leave the home directory editable?

I've tried a LOT of stuff with chmod and chown, and combinations thereof. I still want the files in the home directory of this user to be readable to the user, just not writable or executable. ...
1
vote
2answers
71 views

How to split a large folder into smaller folders of equal size [closed]

I have one big folder with many file types in it (e.g .txt, .sh). It's about 40Gb. I would like to split it into four parts of 10Gb each. How can I achieve this?
0
votes
1answer
37 views

Trying to remove current directory using rmdir

I created a directory dir at Desktop and then i keyed in cd dir so as to make dir as my current directory and then i typed in the terminal rmdir /home/user_name/Desktop/dir from the dir directory ...
0
votes
3answers
47 views

Using find to list directories that haven't been accessed since a certain date?

Using the stat command one can see and format the last date a directory was accessed. The adate Is it possible to use find to find the directories that were changed before a certain date using a ...
0
votes
2answers
81 views

Unzip to a folder with the same name [duplicate]

How to unzip a file (ex: foo.zip) to a folder with the same name (foo/)? Basically, I want to create an alias of unzip that unzips files into a folder with the same name (instead of the current ...
-1
votes
0answers
33 views

Script finding the total size of a directory and checking if a directory exists

I need one additional line for my script that finds the total size of a directory and shows it in bytes and another line in the beginning of this script that checks if a directory exists. That's my ...
0
votes
0answers
33 views

Complex nested for loop in directory

I have two sets of files in two separate directories organized as such: #first directory /direc1/files file0.num1.tar.gz file0.num2.tar.gz file0.num3.tar.gz file0.num4.tar.gz . . . ...
0
votes
1answer
41 views

Where should I store my application files (data, cache, logs, crashes, etc.) [closed]

Although I did some research on this subject, I couldn't reach the exact information I wanted. Actually, not exactly disclosed, everyone approached in a different way. For the: Filesystem Hierarchy ...
1
vote
2answers
75 views

find: exclude n different directories and m different files present at any level but include few files from some excluded directories

I want to recursively find all directories and files inside a path but want to exclude some other directories and files that match given patterns. I then want to execute further commands on the search ...
1
vote
1answer
89 views

I want to find if a word exists in a file

I have a directory with some files. I want to know if a word exists in each file. $1 is my directory that I give it as a parameter e.g. ./myscript.sh /mnt/c/User/er/Desktop/shows I have written ...
0
votes
1answer
39 views

Creating text files in every sub-directory

I have a directory hierarchy named, for example, abc and a text file names.txt. I need to choose several lines from the text file and then create new files with sample text, say "Hello world", in ...
0
votes
1answer
39 views

Meaning of dot (.) in The Following Examples

I would like to know the meaning of the dot (.) in the following examples: dotslash at the front of the path: cp -r ./dist/amd/ ../../aurelia-amd/animator-css Is this equivalent to cp -r dist/amd/ ...
1
vote
1answer
38 views

On FreeBSD, or other BSDs, what directory is commonly used for data folder storing the content of a database such as Postgres

I am wondering if there is a convention on where to store the data folder containing all the files for the tables and rows of a relational database system such as Postgres.
-1
votes
0answers
28 views

Reconstruct changes to the crontab and a directory over 5 Months

Is there any way to show who moved/deleted/restored files at a specific point in time on a linux server and who changed the crontab? Given the case described below, somebody or something either ...
0
votes
0answers
34 views

Exclude the specified directory when use grep [duplicate]

I tried to recursively search $ grep -r "hold stat" . grep: ./C/APUE/apue.3e/figlinks/fig14.21: No such file or directory as a solution, exclude the dir with $ grep -r "hold stat" --exclude-dir ./...
0
votes
0answers
25 views

How to make a certain bash script execute when I enter a certain directory? [duplicate]

I have multiple projects, say, in Python. In each project I have "scripts/main_script.sh". Is there any way to make "scripts/main_script.sh" execute automatically when I go to the base directory of a ...
0
votes
2answers
39 views

Move all but one sub-folder into that sub-folder

I have a directory named temp. Inside this folder, I have multiple sub-folders ( I don't know the exact number ). Now I create another sub-folder inside temp named Untitled. Now I want to move all the ...
2
votes
1answer
61 views

Bash script to move files into folder based on matching ID numbers?

On ~/Desktop/a/ , I have files and folders with this pattern: 500 photodir Photo 500.jpg 1000 origindir Photo 1000.jpg I would like to have the .jpgs moved into their folders, using the numbers ...
1
vote
0answers
11 views

in ldap make the default bind the current logged in user

I do not want to specify a default bind_dn in the sssd.conf file for ldap (either openldap or active directory). Is it possible to configure the system in a way, that the first logged in user becomes ...
0
votes
1answer
30 views

Can bash make folders, based on a filename, and then move files into the folders?

On /Desktop/a/ , there is a set of files: DSCN1840.AVI00001.png DSCN1840.AVI00002.png DSCN1840.AVI00003.png DSCN1841.AVI00001.png What I would like is to have the following structure: Desktop/a/...
1
vote
1answer
47 views

Number of home directories in children of /

I have to count the number of children directories of / that contain one or more home directories. For instance, if john, emily and rick have their home directories in /home/john , /home/emily and /...
0
votes
2answers
35 views

Delete directories if they do not have newer files

I want to delete directories only if they have not changed in the last N days. And by changed I mean contain any files that are more recent than N. I constructed something similar / found this but ...
-1
votes
1answer
87 views

Permission needed to create/remove file in a directory with sticky bit set

I understand that creating/removing a file from a directory with sticky bit set requires one of the followings you are root you are the owner of the file you are the owner of the directory and you ...
7
votes
1answer
451 views

Why ls without -l return 1 when permission to directory is r--

I have read this and this, and found that my problem is different and more specific. I understand the following points. +x on the directory grants access to files inodes through this specific ...
0
votes
2answers
364 views

Is there some tool for finding files in one directory but not in the other? [duplicate]

I would like to write a bash script to find those files in a directory but not in another directory. Does the following script work? When does it not? for i in "$1"/*; do f=$(basename $i); ...
-1
votes
1answer
73 views

Find files in specific directories

I have a college exercise which is "Find all files which name ends in ".xls" of a directory and sub-directories that have the word "SCHEDULE", without using pipes and using only some of the commands ...
0
votes
2answers
71 views

Why `ls -d` only demonstrate `.`?

I'd like to only the directory $ ls -d . #get . on macos and the same on centos [root@iz2ze9wve43n2nyuvmsfx5z ~]# ls -d . . I find the solution: [root@iz2ze9wve43n2nyuvmsfx5z /]# ls -d */ bin/ ...
0
votes
2answers
32 views

How could I copy the same directory multiple times but with a different name?

I have a directory called 400K that has some files in it, I want to copy this directory multiple times but with different names. I want something like: cp -r 400K 500K 600K 700K I was considering ...
0
votes
0answers
29 views

Symbolic Link: Have all programs “think” the target path was entered directly

(Linux Mint, 18.3, based off of Ubuntu 16.mumble) TL;DR I want apps to open a symlink path and not "know" that it's a symlink, but believe that I opened the destination directory directly. Wordy: ...
0
votes
2answers
31 views

Permissions from file and sub directory for all users inherit permanet

Hi I have a directory /home/nvs-upload/media/ImageFtp/ and the directory ImageFTP have many sub directory. The issue than I have is than a job run and add new sub directory it add to the new directory ...
0
votes
1answer
31 views

Is “dir” command output same accross all distributions of Linux (such as Ubuntu)?

I'm preparing a batch compiling sh file in Ubuntu. It is using dir command to get a list of files (and some string processing to extract names). But this may not be the best way (but easy enough) of ...
0
votes
0answers
20 views

How can I be able to `mv` a directory owned by root? [duplicate]

System: Linux Mint 19. Situation: I do not understand the following. How can I be able to mv a directory owned by root? Some information, that might be useful: Actual working directory: $ pwd /...
2
votes
1answer
52 views

Is pCloudDrive really inaccessible to root?

pCloud is a cloud storage service that allows Linux users to mount their cloud storage inside of their home directory, appearing as: /home/username/pCloudDrive/ As far as I can tell, the pCloudDrive ...
0
votes
2answers
34 views

Shell script to move empty folders into a subfolder

I have many empty folders that I do not want to delete but move to a subfolder called "my_empty_folders". How can I do that in a shell script?
0
votes
3answers
47 views

Cut path to first four directories

I have several projects where I have to use the same command. The projects always are in /home/[username]/public_html/[prjectname]/ I'd like to run this command from every directory of my projects, ...
0
votes
2answers
39 views

How to list directories with particular depth? [duplicate]

I want to list only those directories which are a particular depth from current directory. Let's say depth=2 The directories listed can be: ./abc/abc ./xyz/xyz If depth is 3 ./mvd/123/abc etc.
0
votes
1answer
95 views

How to delete all directories inside a directory except for files, (safely)?

Environment System: Linux Mint 19 Cinnamon. Shell: Bash version 4.4.19(1). Problem Along with hundreds of testing scenarios, I must have created countless of temporary installation directories ...