Use this tag for questions about file management and operations on files.

learn more… | top users | synonyms (1)

2
votes
1answer
15 views

read only symlink or something similar?

I created myself a NAT for home use (Ubuntu+Samba+Greyhole+Apache+MySQL+other web server related stuff). 90% of files I store there are pictures that i really don't wanna loose (that's why Greyhole). ...
2
votes
1answer
104 views

write() system call ignores file permissions

I made a very simple program in C which writes "Test string" into file named "file.txt": root@3:~# cat test.c #include "unistd.h" #include "string.h" #include "stdio.h" main() { FILE *fp; int ...
5
votes
1answer
76 views

Ability to add files to a directory but not remove existing files

Is there some permissions setup that would allow a user, say, john, to add a file to a directory d, but not be able to remove an existing file owned by another user, say, root? My understanding is ...
1
vote
2answers
139 views

I accidentally GZIPed a whole bunch of files, one by one, instead of using tar(1). How can I undo this mess?

I'm new to the gzip command, so I googled some commands to run so I can gzip an entire directory recursively. Now while it did that, it converted each of my files to the gzip format and added .gz to ...
3
votes
1answer
32 views

Find Stale NFS Files

I've been pondering about an efficient way to locate stale NFS files for a few days with out much success and was wondering if there are better approaches to the problem. Problem: every once in a ...
6
votes
3answers
421 views

How can I make a special file that executes code when read from

Most files on a Linux system are normal files, i.e. they are saved on disk and reading from them just reads from a specified chunk of memory on the disk. How can I make something that behaves like a ...
1
vote
2answers
47 views

finding latest date and date modified file and using sed

I have a series of files that contain a date and I need to get the file which has the latest date, and the latest date modification and pipe it to sed. I have tried various approaches and I cannot ...
8
votes
2answers
226 views

Reindexing a large CSV file

I went through the answers in this helpful thread, but my problem seems to be different enough that I can't think of good answer (at least with sed). I have a large CSV file (200+ GB) with rows that ...
3
votes
1answer
32 views

Linux: Locating text file from a string input

I have started to use Linux and I'm practicing using/making codes to locate and do things. I need help with code that locates any file from a string of input. I don't know where to start?
4
votes
5answers
153 views

Clone directory tree structure and copy files to the corresponding directories modified after a specific date

I have a folder with more than 30 sub directories and I want to get the list of the files which was modified after a specified date(say sep 8 which is the real case) and to be copied with the same ...
2
votes
2answers
26 views

Run grep or other commands on files on a web server

I have files on another domain. What's the best way to use commands on them like grep? wget http://path/to/file.txt | grep search However this doesn't work. I guess I can use curl but is there a ...
3
votes
2answers
30 views

zsh solutions to “the argument list is too long”

I read in this answer from @Gilles the following: In zsh, you can load the mv builtin: setopt extended_glob zmodload -Fm zsh/files b:zf_\* mv -- ^*.(jpg|png|bmp) targetdir/ as a solution to ...
2
votes
1answer
26 views

Compress a tar file without extracting the content

Is it possible to compress a tar file such that I don't end up with an archive file in an other archive file but just an archive file containing my content fx. a tar.gz file? I don't want to extract ...
1
vote
1answer
23 views

Root is receiving “operation not permitted” error when trying to move a a users .bash_profile

This are the permissions on the RHEL5 machine: [root@server1 belmin]# ls -la | egrep '\.(bash_profile)?$' drwx------ 9 belmin belmin 4096 Sep 16 14:29 . drwxr-xr-x 40 root root 4096 ...
2
votes
2answers
51 views

How to make my bash script be able to create an log file for a clamscan running in cron?

I've created an custom clamscan(clamav) in bash and when I run it in my shell everyhing is fine, but if I run it in a cron, it can't create the log file. This are the errors: ...
0
votes
2answers
51 views

Removing duplicated files in the rootfs - to speed up booting time, and improve memory usage

With Buildroot I'm making images for my Embedded Linux Hardware. Mainly I'm trying to speed up the boot sequence (and on the way lower the memory usage), where I've tried many techniques successfully. ...
1
vote
1answer
36 views

dialog menu to display files and select one of them

I want to display all the files under /home directory in menu, and select only one of them. Then the script will print the full path of the selected file. I have created the following script. This ...
-1
votes
3answers
39 views

Delete oldest files from a directory if number exceeds seven

Daily downloads are stored in a directory. A script has been created which counts how many files reside in this folder. The part I am struggling with is deleting the oldest file in the directory if ...
-1
votes
1answer
22 views

In Mac Os, what is .DS_store?

In each folder I find a hidden file called .DS_store? What is this exactly?
1
vote
3answers
67 views

Can a file ( such as PNG image ) wear out if transferred via SSH ( scp ) 1000s of times back and forth?

The question is about anything really. But in my case it is PNG images. Can they wear out if transferred in-between servers over and over again? I send them to another server and then retrieve ...
-3
votes
1answer
60 views

Find files using ls and wildcards

pwd : ../bin under bin I have a directory called datafiles. Use meta characters and the ls -lL command (with lower and upper case L) to list all filenames under the datafiles directory that contain a ...
3
votes
2answers
72 views

Extract csv files from path to multiple files in bash

I have a files multiple file path for backup purpose ,now i want to filter it based on ".csv " fromat. I have tried this. filesall=(/home/abc/allfiles/*) files=$((${filesall[@]}|grep -F ".csv")) ...
6
votes
2answers
90 views

How come sed is so fast?

I thought about whether this question is suitable for SE or not, I hope you agree it is. Some time ago I asked on SE how to find text in files and leave the file with only the matching lines that ...
1
vote
2answers
48 views

Delete old files but keep one each week/month/year

I have a folder with log-files each ~10 minutes: alfred_140810-190001.json alfred_140810-191001.json alfred_140810-192002.json alfred_140810-193001.json alfred_140810-194001.json ...
0
votes
2answers
22 views

How to make partitions with in /home/user/ writable by user?

I have a partition scheme like this: / /home/ /home/user/files/ When logged in as user, I cannot save any files at /home/user/files/. The only solution I can find is to create a new subdirectory as ...
3
votes
1answer
297 views

Do files change while passing from ext2 to ext3 to ext4?

If one creates a file on an ext2 (or ext3 or ext4) partition, then moves from one partition to another, each formatted differently, does any part of that file change? Once returned to the original ...
0
votes
1answer
22 views

How to remove a specific string from file name [duplicate]

I have a report running in UNIX and creating a file named xxxx_ddmmyy_hhmm_zzzzzz.txt. I need to remove the zzzzzz from the file name. How do I do it?
1
vote
1answer
36 views

Linux does not see a file until I ls on that directory

I have a really weird problem. I have a php script that runs, submits a child process to run, and waits until its done by checking for a OUTFILE.end file to appear. The problem is the file appears, ...
0
votes
2answers
34 views

Remove by date in Shell Script

I have a shell script that creates a backup of a database. I would like to keep the last 7 days for files. What is the syntax I need to remove files in a directory by date or can I keep the newest 7 ...
11
votes
2answers
184 views

Why does cat x >> x loop?

The following bash commands go into an infinte loop: $ echo hi > x $ cat x >> x I can guess that cat continues to read from x after it has started writing to stdout. What is confusing, ...
3
votes
3answers
244 views

How to integrate mv command after find command?

Given a scenario I was searching for file name which contain AAA withing it on a path using following command: find path_A -name "*AAA*" Given the output shows from the above command, I want to ...
6
votes
2answers
78 views

Operations only on complete files [duplicate]

I have machine on which the files are uploaded by ftp. From this machine I would like to run cronjob and scp/rsync (simply copy them) to different machine in the same network. The problem is I don't ...
0
votes
1answer
15 views

Print output of some my data in a file that should start with first line without blank space

By using some shell command i filter some output Please can some one suggest how i can print this output in some file For example I filtered some line and save it to some file but problem is it is ...
9
votes
3answers
817 views

Open a text file and let it update itself

How can I open a text file and let it update itself? Similar to the way top works. I want to open a log file and watch it update itself on the fly. I have just tried: $ tail error.log But just ...
0
votes
2answers
29 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 ...
5
votes
7answers
636 views

Linux command line. Move all files and directories in directory, except some files and directories

I have a folder A which has files and directories, I want to move all those files and directories to another folder B, except file, file2, directory, and directory2. How can this be done?
3
votes
1answer
23 views

chroot into a sshfs folder

I am trying to chroot into a sshfs-mounted directory: mkdir remoteroot sshfs remote:/ remoteroot/ sudo chroot remoteroot/ but I get chroot: cannot change root directory to remoteroot/: Permission ...
11
votes
1answer
132 views

When did directories stop being readable as files?

I have the 1st edition of The Unix Programming Environment book. In chapter 2, the authors state that directories are readable as files, and mention some facts about the format of these files. They ...
1
vote
1answer
39 views

Create a file that's really a network port

I have a program running on a cluster, and the output of the program is written to a log file which I specify. However, instead of writing it to a file, I want to write it to a network port, so that ...
0
votes
1answer
20 views

Convenient way to upload a file to a server's application directory?

I very often need to upload some kind of file to a server, to put some application directory somewhere. Since my user account is of course unprivileged, I generally have to do this: scp file.txt ...
4
votes
3answers
61 views

What is a good strategy to generate and copy files atomically

I have a file myfile that must be re-generated periodically. Re-generation takes some seconds. On the other hand, I have to periodically read the last (or next to last) file generated. What is the ...
1
vote
1answer
32 views

Log new files in a directory

Is there a tool, which lets me know about the last newly created files? The still common way of using a hierarchically file system makes it hard to save files in different places, so sometimes I sort ...
3
votes
1answer
50 views

Run Script at fail login attempt?

Lately, I've been trying to create a Bash script to capture a webcam photo when a fail attempt to login is registered. First of all, I found 2 guides related to this (links at the end), they explained ...
0
votes
0answers
36 views

get time of file in inotifywait tool

for this script: inotifywait -m /path -e create -e moved_to | while read path action file; do echo "The file '$file' appeared in directory '$path' via '$action'" # do something with the ...
1
vote
1answer
35 views

TCL script try catch

I have a TCL script that sets a number of variables and reads several files. The last file it reads may contain sensitive information, so I need to make sure this file gets deleted even if an error ...
1
vote
1answer
25 views

How does ACL calculate the effective permissions on a file?

I ran the following command to give the wheel group rwx permissions on new files and subdirectories created: [belmin@server1]$ ls -la total 24 drwxr-sr-x+ 2 guards guards 4096 Aug 27 15:30 . ...
3
votes
2answers
46 views

How often is the /etc/shadow file backed up?

From man 5 shadow: /etc/shadow- Backup file for /etc/shadow. Note that this file is used by the tools of the shadow toolsuite, but not by all user and password management tools. What I ...
2
votes
2answers
89 views

find file, copy but with different name

I have files with random numbers in /home/user/files folder (every 4 days I have new ones). for example: john20 john25 john40 tom12 tom32 simon2 simon8 simon53 I want to take only last modified ...
2
votes
3answers
101 views

Convenient way to name files in Linux

I'm a beginner in Linux and want to learn to do things properly in this environment. Since the beginning I've noticed that a lot of people involved in Linux (like tutorials and guides) tend to name ...
0
votes
0answers
37 views

How to remove files except a list with names files [duplicate]

I need delete some .desktop files in various directories and a text file with a list of file names. I want to delete all these .desktop files except for those listed in my text file). Example $ ls ...