Logical entities that contain data in a filesystem. Use this tag if your question: is about programs that create files (e.g. gzip, tar, zip); deals with characteristics of files (permissions, size, path/location); or is about management of files (renaming, listing, moving, removing). For operating ...

learn more… | top users | synonyms (1)

1
vote
2answers
24 views

has a file changed of value [on hold]

im trying to use pyinotify to detect if a file has changed. managed to do it this way def status(argument): global email_alarm_status global new_email_alarm if not email_alarm_status: ...
0
votes
1answer
33 views

Delete files older than X days - mtime, ctime and atime doesn't work

I'm running a script on synology (NAS) that is deleting files older than x days on certain folders. The problem is that I want these files to be deleted after X days of being uploaded on the folder. ...
3
votes
2answers
75 views

How to Run a command on all subfolders

If you have a series of sub folders (like from a to z) and want to run a command on each one of them (like dsmmigrate * & ) how do you do that? The manual approach would be, cd a dsmmigrate * &...
0
votes
2answers
31 views

How to split a 6 or 7 GB file into several sub-2 GB files without splitting entry?

My level has 6 to 10 GB sized files as input. These files contain several lines of data. The next level's max input capacity is 2GB. So I have to split these 6-10 GB files into several sub-2 GB files ...
11
votes
2answers
450 views

How to set file permissions with touch command

It seems that whenever I create file with touch the permissions are set to: -rw-r--r--. Is there some way that I can configure the permissions differently with touch or does this have to be done after ...
0
votes
2answers
60 views

Reading a file incrementally

I have requirement where I need to read part of the file which was updated from the last read. I mean if I read the file last time at 2016-07-26T01:30 and after I want to run again at 2016-07-26T02:...
1
vote
1answer
18 views

perl + uniq characters before variable

Please advise What is the meaning of the characters "%%" before the variable EOF ? $LINE =`tail -1 $FILE `; chomp($LINE); if ($LINE eq "%%EOF") { . . .
1
vote
1answer
17 views

Find capacity details and oldest file in Busybox format

I am using Mobax and it has Busybox installed in it. I can successfully get the capacity, available, used and used percentage of the directory and its sub-directories in Linux by typing: clear &&...
10
votes
2answers
491 views

How do I grant different permissions for each user?

So, I've been using Linux for a few years now, and I really should know this answer, but I'm having trouble finding it. Specifically I've been using Debian based distro's....mostly Ubuntu. If I have ...
0
votes
0answers
42 views

What may go wrong while copying file? [on hold]

I am writing a library as part of learning a new language which copies a file. The task is to copy the file content as using the nodejs Stream API. I am interested in knowing what can happen wrong ...
34
votes
4answers
12k views

Flattening a nested directory

This is probably very simple, but I can't figure it out. I have a directory structure like this (dir2 is inside dir1): /dir1 /dir2 | --- file1 | --- file2 What is ...
0
votes
1answer
35 views

Restore system file permissions

While I was setting up an Ubuntu server (EC2), I accidentally run the following: sudo chown -R www-data.www-data /* very dumb and noob move on my end. Anyway, is there an easy way to restore all ...
56
votes
10answers
134k views

How to list all files ordered by size

I would like to list all files in the order of big to small in size and the files could be present anywhere in a certain folder.
7
votes
5answers
7k views

Delete spaces, hyphens, and underscores in filenames?

What is a good command to delete spaces, hyphens, and underscores from all files in a directory, or selected files? I use the following command with Thunar Custom Actions to slugify filenames: for ...
4
votes
4answers
2k views

How to count occurrences of all the words in all the files of a directory using grep? But with count incremented only once per word per file

I have already asked a similar question but people misunderstood what i was asking. I was asking how to generate a list of every word with a word count incremented only once per word per file. For ...
2
votes
3answers
37 views

Is it “broken” to replace an existing file without fsync()?

In Linux's mount(2) man page, I noticed the following excerpt: Many broken applications don't use fsync() when replacing existing files via patterns such as fd = open("foo.new")/write(fd,...)/...
7
votes
1answer
159 views

Why does OS X `install` errors on redirected input when the same version of `install` on linux works fine?

I would like to use install command in order to create a new executable file with pre-populated content (e.g. with single pwd command in it). So I've extended this example which creates a new empty ...
20
votes
1answer
3k views

gvim -p limit of opened tabs?

When I run : gvim -p *.xyz I find that not all files are opened in tabs. It feels, like a kind of tab limit? But ! When I try to open unopened with : :tabnew it is opened next to previous ...
2
votes
1answer
25 views

Does linux tar block write access to files

I have a large (>10GB) folder full of images on a live webserver that I need to back up and transfer. I'm worried that if I tar the folder, the files will be blocked for reading by the webserver, ...
3
votes
6answers
159 views

How one can re-read image with dd so it will match one you just wrote?

I have a ~1GB image that I'm writing to a 8GB SD card via the dd tool. I'd like to verify that it was written without corruption by reading it back and comparing its hash with original one. Obviously,...
7
votes
3answers
668 views

How can I safely ensure a variable contains only a valid filename?

Given the script below, how can I ensure that the argument only contains a valid filename within /home/charlesingalls/ and not a path (../home/carolineingalls/) or wildcard, etc? I only want the ...
0
votes
0answers
31 views

No such file or directory: But file exists [closed]

I am stuck in a very weird problem. I have a Bash script in a server A which is called from server B using another script. The script from server B returns "No such file or directory". The file is ...
0
votes
1answer
26 views

How can I retrieve the permissions of a file in a certain format? [duplicate]

I can change the permissions of a file by: chmod 600 ~/.ssh/authorized_keys How can I retrieve the permissions of a file in the same format which is 600?
2
votes
4answers
65 views

Extract the directory path containing the file with matching string

I have multiple subdirectories at multiple levels containing a file results.out ./dir1/results.out ./dir2/dir21/results.out ./dir3/dir31/dir311/results.out Now i need to search for string1 in ...
0
votes
1answer
17 views

How to write and handle custom log file properly?

I had a task that I have to write up a simple bash script which in turn executes admin command from Websphere Application Server (WAS). I put it into /etc/cron.daily folder hoping it would be executed ...
11
votes
3answers
7k views

find with -execdir

When I run find with -execdir I don't get the results I was expecting. For example: mkdir -p a/b/c find . -type d -execdir touch foo \; $ tree a a ├── b │   ├── c │   └── foo └── foo Directory c ...
-3
votes
2answers
171 views

Find the number of files with sizes

Find the number of files with sizes > 100KB in /, /bin, /usr, /usr/bin and /usr/sbin directories and output them in a two column format with the name of the directory and the number of files.
0
votes
3answers
1k views

Creating a character device file

How to create the character device files? I have tried cat > xxx^c But I can't create a character device file
-1
votes
4answers
41 views

Extract files from a directory and save the files' names and sizes in KB in a CSV file

I want to retrieve all the .log files from the directory /var/log, store the results in a csv file along with each log file's respective file size in kB. I started by getting the files using find: ...
1
vote
1answer
33 views

Clearing folders except specific type of files

I have tree of folders as follow: parent folder ....folder A ....folder B ....folder 1 ....folder 2 ....folder C ....folder 1 ....folder 2 ....folder D ....folder 1 ....folder ...
1
vote
2answers
50 views

Unable to delete files through Terminal

More recently, I have been using rm -r /path/to/file to delete files, but when deleting from certain locations, I get the error: override rw-r--r-- root/admin for filename? I have tried entering y, ...
3
votes
2answers
44 views

Protect session log from being written again by anyone

We have implemented a workaround to save command history in a new file for each user session for audit purpose. So each session file is identified by the start time and the username. The problem: The ...
1
vote
2answers
37 views

list files with similar names sorted by similarity [closed]

Is it possible to search files and list them descending by similarity ? e.g.: Following files are in /: heo HELLO helo hello When I search for 'hello' I would like to have a List like: ...
1
vote
1answer
31 views

How do I find files with multiple empty lines?

For replacing multiple empty lines with just one I need to find which files to apply this in the first place, in a big repository. How do I do that?
4
votes
3answers
189 views

Shell script: “if file is not being used” condition

I'm trying to compress a virtual machine image file through a script, but I want to be sure the file isn't being accessed. I could check if virt-manager is running, since it should be the only program ...
4
votes
2answers
1k views

Why does touch create new files?

I am aware that the touch command is used to update the date of last modification on a file. It is also used to create a new file if requested file does not exist on file system. Since touch (as it's ...
71
votes
6answers
62k views

What is a Superblock, Inode, Dentry and a File?

From the article Anatomy of the Linux file system by M. Tim Jones, I read that Linux views all the file systems from the perspective of a common set of objects and these objects are superblock, inode, ...
4
votes
1answer
67 views

accessing path from outside the root with symlink

I need to add an outside path to my apache configuration. (httpd) so, I made a symlink to this path in my httpd root folder, the path is: /var/log/httpd/ (I want to display logs directly in my ...
1
vote
2answers
1k views

How to give sftp access to sub-directory only not to parent

I want to give SFTP access to user tom for directory /var/www/html/my_project/. while I don't want to give any SFTP access to directory /var/www/html/. currently /var/www/html/my_project/ and /var/...
2
votes
2answers
343 views

How to remove a file that can be seen but no program can seem to touch?

I'm trying to remove some obsolete backups, and deep inside one I've found a file 'cifs3bee' that I can find no way of removing. (And since I can't remove it, it's preventing the removal of the entire ...
2
votes
3answers
108 views

Writing an unlimited number of defined values into a file [closed]

I can use /dev/zero or /dev/urandom to write values into a file. Is there also a way to write an unlimited amount (just restricted by a command line switch maybe) of defined numbers (e.g. 1, 2, etc.) ...
1
vote
1answer
75 views

Limit a directory to have only 1 file?

Is there a way to restrict a directory to have only 1 file? I created a specific directory for a user and I would like to limit that directory to have only 1 file. If that user wants to store new ...
3
votes
2answers
56 views

renaming mp3 files starting with “-”

I've extracted songs from my ipod, but when doing so, every song was renamed "- [original name of the song]" . I wanted to write a bash script that would remove that first "-" because there are maybe ...
1
vote
1answer
19 views

server file owner and group changed when editing file locally [duplicate]

If i edit the file from a remote server via text editor (geany, sublime text..etc) locally, the file user and group will changed to the logged user. Let say if I accessing the remote file with root ...
1
vote
2answers
32 views

Install the content of a folder into another

I'm trying to write a Makefile to install the content of my folder into another on the system. I would like to keep the same directory structure, like this. localfolder ├── a └── b ├── c    ...
4
votes
2answers
71 views

Is it possible to find files created between two specific times while ignoring the dates?

I have a time lapse of thousands of jpgs and would like to know if its possible to list only the shots taken during daylight hours? So it's not about listing the files between two dates, but listing ...
2
votes
1answer
85 views

Move all files into subdirectories named after beginning of file name

I have a directory that contains quite a lot of files with names made up of 8 random letters, numbers, _ and -, e.g.: 0dckGYH5.jpg 32Pz5-WQ.png 32_17pxH.png Hsf4BQW9.jpg xh-fa3Nu.gif zYtBEaKA.png ... ...
1
vote
2answers
49 views

Scan for file changes in some directories once every 6 hours

I've had some security issues lately and as I can't be totally sure that my code is secure, I have been thinking about scanning some folders and get notified when a file is changed or a new file ...
1
vote
1answer
917 views

Apache created files and its permissions for CentOS 6.x

In short, I have an authenticated HTTP-POST that: posts a jpg image (created as 666 apache:www) into /directory1 (777 ftpuser:www) creates /directory2 (created as 666 apache:www) in a 777 ftpuser:...
3
votes
1answer
371 views

Delete all files with executable permission in a directory

I am in need of deleting all executable files from a directory. My directory contains some configuration files and executable files, and I need to delete all executable files that I don't want. For ...