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

learn more… | top users | synonyms (1)

15
votes
4answers
16k 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 ...
33
votes
3answers
113k 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 ...
24
votes
3answers
11k 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
2k 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
3k 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
233 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..?
8
votes
3answers
2k 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 ...
1
vote
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
565 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
544 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
511 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 ...
2
votes
2answers
835 views

How do I dereference links when extracting from a tar file?

If I have a tar file, bob.tar, which contains real_file and link_to_real_file, in which the latter is a symlink, is there a way to extract the contents of bob.tar so that link_to_real_file will not be ...
4
votes
2answers
799 views

Counting files in leaves of directory tree

I came up with the following snippet for counting files in each subdirectory: for x (**/*(/)); do print $x; find $x -maxdepth 1 -type f | wc -l; done The command outputs consecutive pairs (one ...
2
votes
3answers
2k views

find top 10 latest modified files

How do I get the last 10 files that were modified on my system. I have a system where its disk usage is maxed out I am not sure which files is increasing rapidly. I have a mysql instance stored on a ...
9
votes
4answers
3k views

Is there MD5 (or similar) to a folder? How to verify if two folders are equal?

I'd like to find an md5sum (or similar calculation) of a folder without compressing it into an archive. For example, if in the folder MyFolder we have the files 1.txt, 2.txt and 3.txt, containing: ...
8
votes
6answers
8k views

Shell script for moving oldest files?

How do I write a script for moving just the 20 oldest files from one folder to another? Is there a way to grab the oldest files in a folder?
1
vote
1answer
253 views

Check a bash variable against a file

I have a bash variable ($HTTP_COOKIE) which contains a string. I want to check if this string matches the content of a given file (token). I'm working on a busybox linux. How should I do?
5
votes
3answers
3k views

Write access without read access

Is it possible for a user to have a write access to a file and not be able to read it? How is it possible? I tried the following commands: debianbox@debian:~/posix/io$ touch filetest ...
9
votes
1answer
3k views

Why can't I have a folder and a file with the same name?

I've never had this problem before, but for some reason, I can't rename my folder to packages/. This is the structure: root - packages_old/ - packages When I try to rename the folder with ...
13
votes
3answers
6k views

Getting size with du of files only

How can I get the size of all files and all files in its subdirectories using the du command. I am trying the following command to get the size of all files (and files in subdirectories) find . ...
11
votes
5answers
16k views

Linux ls to show only filename date and size

How can I use ls in linux to get a listing of filenames date and size only. I don't need to see the other info such as owner or permission. Is this possible?
1
vote
1answer
2k views

How to trace file locks (per directory)

I'm quite new to Linux and I have not really a clue on how to do this. I've got a directory and I'd like to monitor (output to shell) when a file inside that directory get's a file lock and when it ...
4
votes
0answers
159 views

Repeatably generate a read error for testing? [duplicate]

I'm trying to test the error handling in some software, in particular what happens when an error occurs reading from a file or pipe. Is there a simple way to send a certain amount of data to stdout ...
-1
votes
2answers
3k views

How to make tree output only directories?

150 directories I can handle but 900 files is too many for a review. I've no manual entry for tree so maybe I can ask you if you know how to output only directories since files get too detailed? . ...
10
votes
5answers
3k views

What's so special about directories whose names begin with a dot?

I was wondering what the difference between these two were: ~/somedirectory/file.txt and ~/.somedirectory/file.txt It's really difficult to ask this on Google since I didn't know how to explain ...
5
votes
3answers
880 views

How can I exclude files by default with rsync?

How can I exclude files by default with rsync? Here is how my normal rsync syntax starts out: rsync --exclude ".ht*" --exclude "error_log" --exclude ".DS*" --exclude "old" ... I've seen a lot of ...
0
votes
1answer
153 views

+x permission for files in directory

I'm an Ubuntu user and I'd like to change default permissions for downloaded files. Currentely all downloaded files are automatically saved with "-rw-r--r--" permissions (umask 0022). I'd like to add ...
2
votes
1answer
2k views

Is the file table in the filesystem or in memory?

In the context of operating system control tables, does the term "file tables" refer to a data structure that is part of the filesystem, or that is in main memory (and in which case I assume it would ...
3
votes
2answers
415 views

On touching a new file why is mtime and ctime older than atime?

I have this: $ ls -l ff ls: cannot access ff: No such file or directory $ touch ff $ stat ff File: `ff' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: ...
2
votes
4answers
174 views

Lines 1,2,3,4,…,n-1, n to lines n,n-1, …,4,3,2,1

I just realized that I could solve this problem by reversing line numbers from 1, 2, 3,...,n to n, n-1, ..., 3,2,1 and then use the same logic as earlier. So I want to know how can I reverse the order ...
2
votes
4answers
2k views

SAMBA Share - Keep user from deleting a file

I'm creating a hidden "Access Log" .txt file of employees accessing a program I've created and need to know how to make it so this file cannot be deleted. Reason being, this program helps to automate ...
2
votes
2answers
525 views

Comparing files and their properties

I get information of a certain set of files in my mail every day, which looks like this: 58623208 Sep 14 20:08 blbn_blfbe_drv 57904920 Sep 14 19:54 blbn_cycmn 55814208 Sep 14 06:02 clsa_Upd 38912000 ...
24
votes
3answers
7k views

Clone ownership and permissions from another file?

Is there a command or flag to clone the user/group ownership and permissions on a file from another file? To make the perms and ownership exactly "like" that of another file?
28
votes
2answers
24k views

How do I do a ls and then sort the results by date created?

In what order are the dated ordered by? Certainly not alphanumeric order. ls -lt sorts by modification time. But I need creation time.
5
votes
2answers
765 views

More sophisticated file command for deep inspection?

Sometimes it seems that the standard file command (5.04 on my Ubuntu system) is not sophisticated enough (or I am just using it wrong, which could well be). For example when I run it on an .exe file, ...
1
vote
2answers
194 views

Splitting giant files into a specific number of lines

I have a CSV that is 40 000 lines long. What is the simplest tool to read from line x to line y? I am sure there are more professional ways to do it but I would just like a bash script that works in ...
9
votes
3answers
2k views

Why is sorting files by access time not working?

I tried to use command ls --time=atime it was working in one directory but wasn't working in another directory. I opened certain files in vim, evince and other applications but after the command file ...
3
votes
3answers
343 views

Delete files in a directory which are also in another directory

I copied a directory using this: cp -r dir/ ../../ without thinking and realized that it copied the contents of dir instead of actually dir to the above directory. Now I have a mess of files I need ...
0
votes
1answer
214 views

Listing only the files in a folder and inside its subfolders

Is there a linux command for getting only the files in a folder and inside its subfolders? I have used the find command, but it is displaying all the files and folders. I am executing this shell ...
3
votes
2answers
324 views

Organizing messy folder based on filetype

I have music lying on my desktop and in my downloads and Music folders. Similarly, I have .odt files lying all over my home folder (mainly desktop). Is there a tool (preferably GUI so my parents can ...
2
votes
3answers
584 views

Rename files with random characters from sha1sum. Does it unique?

I'm using this command to rename files with random characters from sha1sum and move all files from subdirectories to current directory: for fname in `find . -type f`; do mv "$fname" $(echo "$fname" | ...
4
votes
2answers
1k views

Tell if a folder/file is hidden in Mac OS X

I know you can set or unset the hidden flag of a folder/file by doing chflags hidden foo.txt and chflags nohidden foo.txt. But is there anyway of telling whether the folder/file is currently hidden ...
15
votes
3answers
6k views

List the files accessed by a program

time is a brilliant command if you want to figure out how much CPU time a given command takes. I am looking for something similar that can list the files being accessed by a program and its children. ...
41
votes
4answers
9k views

What's the point in adding a new line to the end of a file?

Some compilers (especially C or C++ ones) give you warnings about: No new line at end of file I thought this would be a C-programmers-only problem, but github displays a message in the commit view: ...
4
votes
2answers
1k views

Access history of a file

I was wondering if there are any tools to keep track of the access history of a file. I know of stat, but as far as I understand, it only returns information about the last time the file was accessed. ...
2
votes
1answer
781 views

Can't see files on my cell phone

I have Samsung Galaxy S2 as my cell phone and Debian Squeeze as my desktop. When I connect them using USB, Debian recognize it and allows to open it with file manager. Problem: it displays only ...
8
votes
4answers
3k views

How are directories implemented in Unix filesystems?

My question is how directories are implemented? I can believe a data structure like a variable e.g. table, array or similar. Since UNIX is Open Source I can look in the source what the program does ...
11
votes
2answers
3k views

recursive statistics on file types in directory?

I did a website scrape for a conversion project. I'd like to do some statistics on the types of files in there -- for instance, 400 .html files, 100 .gif, etc. What's an easy way to do this? It has to ...
6
votes
3answers
11k views

Correct permissions for /var/www/html?

I'm able to write changes in the home directory, but when it comes to the /var/www/html folder, it's not allowing me to make any changes or create new files or folders. I'm able to view the files in ...
4
votes
3answers
9k views

How to recursively list all hidden files and directories?

I want to list all hidden files and directories and then save result to file. Is there any command for this?