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

learn more… | top users | synonyms (1)

3
votes
3answers
3k views

How can I change the date modified of a folder to the last changed file inside? [duplicate]

In my media center directory all modified times of my folders are somehow not the desired date. How can I change all modified times of the main folders to the modified time of the newest media-file ...
0
votes
1answer
59 views

Get the most recent backup files [duplicate]

I'm googling for this, but the terms are so generic I'm getting way too many false positives, so what the hey, I'll ask here. I'm sure there's a simple answer but I don't generally script in *nix. ...
3
votes
2answers
2k views

Finding sparse files?

Is there a straightforward way to find all the sparse files on my system, or in a particular directory tree? If it's relevant, I'm using zsh on Ubuntu 12.04, although a more generic Unix-y answer for ...
2
votes
2answers
230 views

Symbolic link of for my user, doesn't work for root

I am experimenting with the following scheme in order to share common data among different distributions. In Fedora I have created a symbolic link /home pointing to: ...
3
votes
1answer
761 views

viewing dll and exe file properties/attributes vi command line

I have a need to see some additional file properties for exe and dll files. If I open windows explorer and add the additional columns to my view, I can see things like Company, Copyright, Product ...
1
vote
1answer
73 views

Mass file+folder+directory move

So we have a bunch of src files that are old and out-dated and need to be moved to our new NAS storage. (I don't know why we are keeping them). Is it possible to copy all the files and folders with ...
5
votes
2answers
15k views

How to list processes locking file?

Using flock, several processes can have a shared lock at the same time, or be waiting to acquire a write lock. How do I get a list of these processes? That is, for a given file X, ideally to find the ...
2
votes
3answers
974 views

How can a group own a file?

Whe I do ls -l, two of the fields are username of the owner and name of the owning group. The username is clear - I created the file, it is mine. However the group entry confuses me. My user is a ...
3
votes
3answers
3k views

Grep in couple thousands files

I have directory with cca 26 000 files and I need to grep in all these files. Problem is, that I need it as fast as possible, so it's not ideal to make script where grep will take name of one file ...
2
votes
3answers
446 views

zcat a file line by line? [closed]

I have written a C++ application that reads files line by line. It reads one line, does processing, then reads the next line. I would like to add support for gzipped files, and am looking to an ...
5
votes
5answers
367 views

Split the content of a file in linux

I have a text file which has content like this: abc.tar^@xxx.tar^@yyy.tar^@ Say for example I have this content in a file named abc.txt and I want to split the content and write the first two ...
-3
votes
1answer
98 views

Is there a way to tar multiple files in a directory (Linux/Unix)?

Is there a fairly simple way to tar several (specific) files in a directory? For example let's say the following is a directory: -rw-r--r-- 1 allend bin 98 Jul 20 15:50 scriptlog.log -rw-r--r-- 1 ...
6
votes
1answer
4k views

How to circumvent “Too many open files” in debian

If I want to see all relevant log files of my apache2 server at once, I use tail -f /var/kunden/logs/*log /var/kunden/logs/*log /var/log/apache2/*log |grep -v robots|grep -v favicon But since those ...
4
votes
2answers
59 views

List all directories that do NOT have a file with a given file name inside

How would I go into listing all directories that do not have a file with a given file name inside? e.g. given this tree / /a README file001 file002 /b README file001 /c ...
5
votes
3answers
660 views

Getting relative links between two paths

Say I have two paths: <source_path> and <target_path>. I would like my shell (zsh) to automatically find out if there is a way to represent <target_path> from <source_path> as ...
2
votes
3answers
699 views

clone root directory tree using busybox

I have an TI DaVinci-based (ARM architecture kin to OMAP) system which netboots using TFTP and NFS-mounted root filesystem, and am trying to make it boot standalone without a netboot server. The ...
4
votes
2answers
109 views

When I move a file to a different directory on the same partition, does the file's data actually move on disk?

I could see it going both ways. If the filesystem stores it's directory structure and list of files in each directory, and then points to the disk location of each of the files, it shouldn't require ...
6
votes
1answer
6k views

delete files matching pattern

I need to recursively remove all files in all subdirs where the filename contains a number followed by an 'x' followed by a number, at least two times. Example: I'd want to remove these files: ...
2
votes
2answers
208 views

How do I only copy files to a destination that exist in the folder from the source, everything else should not be copied

How can I copy files from source to destination, where in all the files existing in destination (with directory structure), only should be copied from the source, overwritten in the destination. Rest ...
2
votes
1answer
86 views

Why do I get one more number of bytes reported in a file?

Why do I get one byte more reported? I do not have a newline at the end. I tested other files with similar result. Using linux 3.2. $ cat testfile.txt aabbcd $ wc -c testfile.txt 7 testfile.txt ...
0
votes
2answers
726 views

/dev/null-like automatic trash directory for file moves?

I can (redirect) textual output to /dev/null in order to get rid of it. This is quite handy because this way I can easily enable/disable it in my bash code. Now I have a script that processes files, ...
1
vote
1answer
663 views

Where is the trash folder in FreeBSD / PCBSD?

I'd like to delete - undelete files using the shell in PCBSD. But... I don't know where the "trash" folder is. Can anyone tell me?
3
votes
2answers
159 views

How to make directory modication date change when files from that dir change?

For example, if a file has been changed in that directory, then directory modification date should be updated. Basically any changes that happen in that directory should trigger a "touch" on the ...
3
votes
2answers
122 views

Is it possible to create a “file” that can be used by any process without actually saving the file on disk?

Suppose I do a grep that gives me a lot of results. I want to use the output of grep and pass it to a command that takes a filename as it's first argument. For example - myCommand filename.txt I ...
3
votes
4answers
7k views

How to read a .war file?

I am trying to view the content of a .war file. I first did set its permissions with chmod 777 then when I try to accces it using: cd /usr/local/standalone/deployments/Sample.war/WEB-INF/classes/ ...
4
votes
3answers
3k views

How can I revert a chmod on the etc directory?

I accidentally executed the following command on the etc directory: sudo chmod -R 700 /etc I know that I have done something very wrong. My terminal now prints: I have no name!@ubuntu: /$ How ...
-1
votes
3answers
215 views

How can I pass a whitespace-delimited values file as a series of arguments?

Say that I have a file with a list of packages I want to install, separated by spaces or newlines. How can I pass that file to my package manager?
0
votes
1answer
801 views

Use sudo tee with heredoc to append to existing file

From Generate script in bash and save it to location requiring sudo we have this method, which I like: sudo tee "$OUTFILE" > /dev/null <<'EOF' foo bar EOF However, I would like to use that ...
6
votes
3answers
393 views

How do you create a file with an empty name?

I don't know how, but I created a file with an empty file name, I doubt there was a whitespace there (I'll explain why at the end): chaouche@karabeela /mnt/ubuntu/storage $ ls total 352K drwx------ ...
2
votes
2answers
47 views

Average number of subdirs

I have a directory which contains a number of subdirs. Each of these subdirs again contains a number of subdirs (call them subsubdirs). Now I would like to count the average number of subsubdirs in ...
1
vote
2answers
2k views

Cheapest way to find the oldest file (recursively) from a directory under heavy load

What is the least expensive way to find the oldest file in a directory, including all directories underneath. Assume directory is backed by SAN and under heavy load. There is concern that "ls" could ...
3
votes
3answers
554 views

Determine the last 7 days backup size

Consider I have a folder /home/abdul/backup which contains .gz file for the past 1 year...My requirement is to get the size of last 7 days...
0
votes
0answers
33 views

Ubuntu directory permissions - Sticky bit - Prevent deletion of a file [duplicate]

I have a database called oss-pwds.kdb located in a folder /keepassx. This is a password database that I use with the KeePassX software. I want to allow all members of the "oss" group to open and ...
1
vote
1answer
311 views

Bash script to hide/show files

I prepared a little bash script to toggle the visibility of my hidden OS X files. if (defaults write com.apple.finder AppleShowAllFiles FALSE); then defaults write com.apple.finder ...
1
vote
2answers
294 views

MacOsx - Shell - list all .php files and their octal permissions, inside a specifc folder

is it possible to list all the ".php" files located into a direcotry and their octal permissions? I would like to list them like this: 775 /folder/file.php 644 /folder/asd/file2.php etc...
8
votes
4answers
4k views

View permission / owner of full directory tree

I remember doing someting like "XXX /home/user/dir/child/file" and it returned the owner and/or permission of: /home /home/user /home/user/dir /home/user/child /home/user/child/file But I don't ...
12
votes
4answers
7k views

How to check if a user can access a given file?

*nix user permissions are really simple, but things can get messy when you have to take in account all the parent directory access before reaching a given file. How can I check if the user has enough ...
2
votes
1answer
66 views

Why do text editors set the mtime on save when no changes have been made?

When I am using sublime, and I've made no changes then the icon in the editor shows the file is unchanged. However, if I click to save it, it still sets the filesystem mtime time to now. Should a ...
1
vote
2answers
96 views

how to count number of differences in large streams quickly?

I want to count the number of differences (different bytes) in two large streams (devices/files). E.g. two hard disks, or one hard disk and /dev/zero. The program(s) involved must be fast, as fast ...
2
votes
2answers
386 views

Understaning of diff output

I have file1.txt this is the original text line2 line3 line4 happy hacking ! and file2.txt this is the original text line2 line4 happy hacking ! GNU is not UNIX if I do: ...
0
votes
3answers
45 views

how to touch files like report-07/05/13

when I want to touch files like report-05/07/13 with command touch report-$(date +%D) it gives me an error like this: touch: cannot touchreport-07/05/13': No such file or directory` How can I build ...
4
votes
3answers
629 views

How to capture stdout of a running process redirected to /dev/null

I want to capture stdout of running process whose stdout is being redirected to /dev/null. I tried using system call fcntl(), however the moment I close fd "1", it was being allocated for other files ...
0
votes
2answers
1k views

Ubuntu : unable to copy file to dir created under same credentials

I am Windows 7 remoting to Ubuntu 12.04.2 LTS I am new to Ubuntu ( and *nix in general ) and need to understand how permissions are assigned to newly created dirs. Via Putty ssh session : $bash ...
1
vote
3answers
698 views

Renaming or making filenames unique

I have written a plsql procedure using utl file to create files in the temp directory in Unix. I am sending the names of the files to a shell script to mail these files and delete after mailing from ...
4
votes
3answers
1k views

limiting size of logfile from a variable

How can I limit the size of a log file, which is saved in the form of 'foo.txt', from within a bash script please? I want to put in the variables 'LOGFILE=50 mb' and it uses that size, or whatever ...
1
vote
2answers
60 views

Copying Files in a Folder To Individual Folders

This might sound like something quite odd but for my HTPC, I need to rearrange how my files are stored such that each of the individual files in a folder needs to be moved to a subdirectory of its own ...
3
votes
3answers
1k views

Splitting a large binary file into sections determined by context patterns

I have a large (2GB) file that looks like this: ^%%-=-=-=-=-=-=-=-=-=-=-=-=-=-%%^ <binary data> ^%%-=-=-=-=-=-=-=-=-=-=-=-=-=-%%^ <binary data> ^%%-=-=-=-=-=-=-=-=-=-=-=-=-=-%%^ ...
1
vote
1answer
140 views

securing a file on disk with password protection usig strong ssl cipher and view the file in more secured way

I was trying to decrypt a file to standardout and piped its content to a given command. for example cat comand, wc command etc. However I felt the following command can be simplified, any further ...
0
votes
1answer
49 views

Doesn't umask apply to files?

I have set the umask to 0. So: $umask 0000 I do echo 'test' > test.txt And test.txt is created. If I do: ls -l test.txt I see: $ls -l test.txt -rw-rw-rw- 1 jim None 5 Jun 30 22:50 ...
0
votes
2answers
136 views

Merging multiple lines selectively?

I have a large file in which a header line is followed by a string of characters at multiple times. eg: file1 VHBFBJBDSBVVFJBSV SVJBVHJBVJ SVKJBVJBNVKVJV file2 dfhgdgffdghgg SVKJBVJBNVKVJV I ...