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

learn more… | top users | synonyms (1)

3
votes
2answers
2k views

Obtain .avi file info from command line

What is the best way to obtain information as bitrate, framerate, width/height of an movie file (in my case .avi) from the command line? I am looking for a basic tool that works similarly as ...
2
votes
3answers
5k views

How to delete the oldest directory in a given directory? [duplicate]

Possible Duplicate: Shell script for moving oldest files? I have a backup directory that stores x other directories that require backuping. I need something that will run before another ...
3
votes
1answer
152 views

lstat64 fails on existing directory

After trying for a while to debug a failing move_uploaded_file call, I tried strace -s 8192 -o strace.log -f /etc/init.d/apache22 restart This produced, among a lot more output, the following ...
2
votes
3answers
761 views

Is there a way to tell the system to keep a folder to reside in memory?

I'm developing a Java EE web application and I'm trying to speed up the testing process. To do so I was wondering if there is a way to tell the system to keep my build folder in system memory?
2
votes
2answers
3k views

How can I selectively copy files from one directory to another directory?

On Linux, how do I selectively copy most – but not all – files from a directory (dir1) to another directory (dir2)? I do not want to copy *.c and *.txt files to dir2. The cp man page ...
3
votes
1answer
997 views

Access to the files beyond Wine's virtual disks

I'm totally new to Linux. I would like to know if the executables run through Wine have any access beyond the virtual drives provided by Wine (e.g. C:/, D:/)?
2
votes
1answer
199 views

Where can I find a reference to the format of the comment field (field 5) of the /etc/passwd file?

In the /etc/passwd file on my system, the "comment" field, field 5, is inconsistent in its contents. I thought that I could extract it to get the full name of the user. fullname=`awk -F: '$1 == name ...
5
votes
1answer
253 views

suid-root doesn't have effect

A program from apue. #include "apue.h" #include <fcntl.h> int main(int argc, char *argv[]) { if(argc!=2) err_quit("usage: a.out <pathname>"); if(access(argv[1], ...
5
votes
2answers
1k views

Immutable bit on AIX?

Under Linux I can: chattr +i SOMEFILE so that even root can't modify the SOMEFILE. Are there any similar solutions for AIX?
8
votes
2answers
994 views

lsof - age of file

The *nix command lsof gives you a list of open files. Is anyone aware of a way that would also list how long a particular file has been open? Either by using lsof or any other command. I'm using ...
5
votes
3answers
523 views

Shortcut for fast recursive removal

Sometimes I want to delete large swaths of temporary files recursively, and recycle the directory name without waiting for the command to complete. (For example, if I want to nuke and re-checkout a ...
3
votes
2answers
175 views

How do I create a structured list of all the files and directories under a particular directory (recursively)?

I need to have an "image" of a file system without actual contents of the files - just all the names and the structure, so that I can read the file and know what files were stored there and how were ...
3
votes
2answers
380 views

shell howto: save multiple binary data files (jpg) to one file with some additional data and separate again

I have a system with restricted calculational power (fritzbox) and functions (busybox) and an webcam, able to deliver JPG files. Now I'm looking for for a method (based on shell script) to download ...
1
vote
4answers
1k views

Checking for the existence of files against a list

I have a "command" text file that issues a data file download command on each line. I send the command file to bash. However, a small percentage of the downloads fail. Here is the algorithm I ...
18
votes
1answer
2k views

Who creates /etc/{group,gshadow,passwd,shadow}-?

In any linux system I have access to (a couple of Archlinuxes, an Ubuntu, a Debian Sid and a Gentoo) there are the following 4 files in /etc/, all ending with a dash: /etc/group- /etc/gshadow- ...
52
votes
8answers
38k views

How can I edit multiple files in VIM?

I know I can open multiple files with vim by doing something like vim 2011-12*.log, but how can I switch between files and close the files one at a time? Also, how can I tell the file name of the ...
7
votes
7answers
9k views

What's the best way to count the number of files in a directory?

If parsing the output of ls is dangerous because it can break on some funky characters (spaces, \n, ... ), what's the best way to know the number of files in a directory? I usualy rely on find to ...
1
vote
3answers
573 views

Script to count files matching a pattern in subdirectories

I wrote the following script for finding the number of pdf and tex files from the current directory, including the subdirectories and hidden files. The following code is able to find the number of pdf ...
2
votes
2answers
132 views

What file system is my file on? [duplicate]

How do I figure out which file system a given file/directory is located on? (For example, I would like to know if the file/directory is a temporary file in RAM, or if it's stored on disk. And what ...
3
votes
1answer
286 views

Why doesn't *nix keep track of file creation time? [closed]

I know about ctime and mtime and that their behavior is platform dependent. As I understand it, *nix does not have any way of keeping track of file creation time. Is this a historical accident? If ...
1
vote
1answer
466 views

file missing from Desktop screen but can be seen using “ls” under the Desktop directory

I downloaded some files onto desktop. After typing ls under the Desktop directory, I can see these files. However, I cannot see the icons on my desktop corresponding to the files I see with ls. I use ...
1
vote
4answers
887 views

Solaris 10 : Remove trailing blank lines from multiple files

I'm working on Solaris 10.What is the easiest way to remove blank lines from multiple files at once?
23
votes
2answers
33k views

How can I increase the number of inodes in an ext4 filesystem?

I had a problem (new to me) last week. I have a ext4 (Fedora 15) filesystem. The application that runs on the server suddenly stopped. I couldn't find the problem at first look. df showed 50% ...
4
votes
3answers
1k views

How to delete duplicates of files in directory and subdirs?

Is there any fast method to delete duplicates of files based on any hash sum (i.e. SHA1 to be fast). Because I've got some mess in my music files.
2
votes
4answers
1k views

Access the last file (alphabetically) in a directory

I'm trying to open a file with vim from the command line, the file is in a directory filled with automatically generated files that are prepended with a time stamp. Since I don't know the time stamps ...
2
votes
1answer
105 views

Finding out *what* is synchronizing two Linux servers

The last person to maintain these Red Hat servers somehow set it up so they stay in sync -- if I delete files on one it automatically deletes them on the other. I need to set up a new configuration on ...
12
votes
1answer
5k views

How do I enable locate and queue the database to be built?

On a new Ubuntu 10.4 instance, I tried to use the locate command only to receive the error locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory from using this command ...
1
vote
1answer
811 views

Allow Windows file share through a Linux Firewall

I'm struggling to enable NTFS share between two Windows (XP and 7) hosts through a Linux firewall. Here's my setup: [XPMachine-LAN1]---------->[LINUX FIREWALL]---------->[Win7-LAN2] What I ...
3
votes
1answer
204 views

Restricting access to files on an external drive

I was wondering how to restrict access to a specific drive in Unix on the Mac. I was thinking to do this in Terminal where I create a file like this mkfile 6k secure_access. And where secure_access ...
3
votes
1answer
1k views

Lock file from being edited or deleted

I have CentOS and cPanel installed. I want to lock certain files (e.g. .ftpquota) from being deleted through FTP. I tried to change the ownership to root:root or root:lock but it didn't work; neither ...
3
votes
2answers
279 views

Bash - file, arrays and output

I have a file that contains employees names, departments and the cities the employee is in, something like: John IT Chicago Joshua accounting New York Marcy CEO Los Angeles ... I have to transform ...
9
votes
4answers
8k views

creating a sequence of numbers, one per line in a file

Is there a way to create out of thin air, a file that is a sequence of numbers, starting at a given number, one per line? something like magic_command start 100 lines 5 > b.txt and then, b.txt ...
7
votes
5answers
1k views

Can I prevent a file from being created?

We have a machine that runs VMware Server. It constantly creates a file called not_configured in /etc/vmware/, which somehow makes our virtual machines not able to be started. I wondered if there was ...
38
votes
4answers
107k views

How can i count the number of lines of file with common tools in a bash?

I am redirecting grepping-results to a file, and then use cat to show its content on the screen. I want to know how many lines of results I have in my results file and then += it to some counter. ...
5
votes
3answers
2k views

Is there a command to list the compressed file sizes for files within a .zip file?

I'd like to see the absolute size in bytes of each file that has been compressed into single zip file. Having read the zip man page, I'm not sure that that utility can do it. This is on Mac OS X. ...
4
votes
1answer
2k views

Asking rsync to create *any* necessary directories

I have the following loop in zsh: for x in my_folders*; do rsync -adrv $x/foo/bar/ /foo2/bar2/new_dir/$x/ done new_dir does not exist before calling rsync, and I would like rsync to create ...
28
votes
5answers
47k views

Script to monitor folder for new files?

How do I detect new files in a folder with a bash script? I would like to process the files as soon as they are created in the folder. Is this possible to do so or do I have to schedule a script with ...
4
votes
1answer
3k views

Rename All Files with a Certain Name

I'm trying to find certain files with the name "stringx" and replace the name (but not the extension) with "stringy". So basically for stringx.txt and stingx.cs, I'd want stringy.txt and stringy.cs. ...
1
vote
2answers
527 views

Network file sharing with freebsd server

I have a freebsd server at home. I also have other OSes like linux and windows connected to the same network via WLAN (wifi). I want to be able to share stuff (what ever I download ;)) on my FreeBSD ...
29
votes
4answers
31k views

What's the best way to join files again after splitting them?

If I have a large file and need to split it into 100 megabyte chunks I will do split -b 100m myImage.iso That usually give me something like xaa xab xac xad And to get them back together I have ...
50
votes
3answers
158k views

Get file created/creation time? [duplicate]

Possible Duplicate: How do I do a ls and then sort the results by date created? Is there a command in Linux which displays when the file was created ? I see that ls -l gives the last ...
27
votes
4answers
17k views

Reading lines from a file with bash: for vs. while

I'm trying to read a text file and do something with each line, using a bash script. So, I have a list that looks like this: server1 server2 server3 server4 I thought I could loop over this using ...
12
votes
3answers
3k views

Are two files hardlinked?

How can I tell if two files are hard-linked from the command line? e.g. something link this: $ ls fileA fileB fileC $ is-hardlinked fileA fileB yes $ is-hardlinked fileA fileC no
6
votes
2answers
6k views

How can I rename a lot of files using a regex?

I want to rename a lot of files on Mac OS X (10.7.2).. I don't have the perl package for the rename command. My files have names like "T452-102456-0.png" and I want to delete the "-0" part. I know I ...
5
votes
5answers
291 views

Is there a way to see the permissions of all the intermediate directories of a path..?

I have a file path.. Is there any single command to see the file/directory permissions of all the intermediate directories in the path..?
10
votes
4answers
3k views

How to run a command when a directory's contents are updated?

There is a directory A whose contents are changed frequently by other people. I have made a personal directory B where I keep all the files that have ever been in A. Currently I just occasionally ...
2
votes
2answers
1k views

Should I end my text/script files with a newline? [duplicate]

Possible Duplicate: What's the point in adding a new line to the end of a file? What is considered better behaviour: to leave the last letter of the last line to be the last byte of a ...
1
vote
3answers
630 views

How do I track all the most recent file changes on my UNIX system?

Say, either for a Debian system or a Red Hat one.
1
vote
1answer
732 views

Permissions for making some some (but not all) files visible directly under a directory

On wikipedia I read the following: The read permission, which grants the ability to read a file. When set for a directory, this permission grants the ability to read the names of files in the ...
1
vote
1answer
622 views

Sticky bit vs setgid for facilitating shared write access

Say two people with different primary unix GIDs share and need to frequently edit the same file. The users are not members of each others' primary unix GIDs, but they are both members of a common ...