Tagged Questions

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

learn more… | top users | synonyms (1)

4
votes
1answer
405 views

Renaming files from bash in linux

There is a bunch of files of the following format hh-mm-ss.png where hh, mm, ss are hour, minute and second. How can I rename all these files in the directory in a sequential way from 1.png til n.png ...
1
vote
1answer
206 views

How can I monitor if anybody (any process) access is certain file [duplicate]

Possible Duplicate: Access history of a file I know if a file is "being accessed" I can use lsof to see who (which process) is accessing it, but lsof is slow and heavy and I don't think I ...
3
votes
2answers
868 views

Concatenate specific files into one single file

In a folder containing X files, I need to concatenate Y files (where X > Y) together into a single text file. I have the filenames (of Y files) that I need to concatenate. Can anyone please help me ...
12
votes
3answers
18k views

File extensions for unix shell scripts

On wikipedia, the article for .sh says: For the .sh file extension type, see Bourne shell. How about other unix shells? I know that the shebang is used inside the file to indicate an ...
5
votes
2answers
4k views

How to find out which file is currently written by a process

My situation is that from time to time a specific process (in this case, it's Thunderbird) doesn't react to user input for a minute or so. I found out using iotop that during this time, it writes ...
11
votes
2answers
220 views

How to start tailing a file that has not been yet created

I use tail to monitor the progress of jobs that I know will write their progress to disk. Almost always, I know which file they will create before they start running (the jobs are dispatched by a ...
3
votes
3answers
2k views

In Mac OS X Snow Leopard, how can one file's permissions be matched to another?

I need to make the permissions of a file exactly match the permissions of another file in OS X 10.6. I don't see 'getfacl' or 'setfacl' as suggested in some other posts for Linux. And, it doesn't ...
6
votes
1answer
806 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 ...
5
votes
1answer
3k views

mv file without write permission to the source file

I just realised that I can move a file that I do not own and don't have write permissions on. I have write permissions to the directory, so I am guessing that is why I could move it, but in this ...
38
votes
5answers
22k views

How to remove duplicate lines inside a text file?

A huge (up to 2 GiB) text file of mine contains about 100 exact duplicates of every line in it (useless in my case, as the file is a CSV-like data table). What I need is to remove all the repetitions ...
3
votes
2answers
1k views

How to add/replace only modified/updated files recursively for some 2 folders?

So I currently do stuff like: rm -rf ../../../$CLOUD_INSTALL_SUBDIR/lib_boost mkdir ../../../$CLOUD_INSTALL_SUBDIR/lib_boost cp -r ../../../$BOOST_ROOT_DIR/$BOOST_INSTALL_SUBDIR/lib/* ...
2
votes
2answers
161 views

Index names of all the files in a plain text file

I've got this directory full of images, and I can do this: echo *.jpg image1.jpg image2.jpg image3.jpg # and so on How can I get the output in a plain text file in this format? image1.jpg ...
5
votes
1answer
3k views

bash force copy over same file

Our sysadmin has created a backup system that creates snapshots of the hard drive. When I try to restore an older version from the snapshot: cp /path/to/snapshots/foo.bar /path/to/folder/foo.bar ...
15
votes
5answers
7k views

How can I do a “copy if changed” operation?

I would like to copy a set of files from directory A to directory B, with the caveat that if a file in directory A is identical to a file in directory B, that file should not be copied (and thus its ...
15
votes
3answers
13k views

How can I find out how many lines a text file contains without viewing it?

How can I find how many lines a text file contains without opening the file in an editor or a viewer application? Is there a handy Unix console command to see the number?
14
votes
3answers
7k views

How to list files that were changed in a certain range of time?

How can I list recursively all files that were changed between 22.12.2011 and 24.12.2011?
4
votes
2answers
269 views

Can I move a directory with open files?

Imagine a bunch of processes using a /home/user/logs directory. They have some logs open for a longer time.
3
votes
2answers
669 views

Subtracting Binary files

I have 2 Binary Files FileA and FileC Its is such that FileC = FileA + FileB using the cat utility How do I subtract FileA from FileC to get FileB ? PS: I am using Ubuntu Oneiric
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
4k 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
133 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
577 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
755 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
155 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
244 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
795 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
796 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
448 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
152 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
338 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
961 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 ...
13
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- ...
40
votes
8answers
26k 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
6answers
7k views

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

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
560 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
120 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
247 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
337 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
716 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?
21
votes
1answer
22k 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
940 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
103 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 ...
9
votes
1answer
3k 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
672 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
191 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
936 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
257 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 ...
7
votes
4answers
5k 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 ...