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

learn more… | top users | synonyms (1)

32
votes
7answers
72k views

How to list all files in the size order

I would like to list all files in the order of big to small in size and the files could be present anywhere in a certain folder.
0
votes
3answers
107 views

How would an administrator of a system prevent himself access to a file for 24 hours?

How would a single administrator go about locking himself out of a file for 24 hours? By "lock" I mean prevent access. I have removed the 'rules' placed on the original post, as it is clear that the ...
23
votes
2answers
4k views

How do I make a file NOT modifiable?

While logged in, I can do the following: mkdir foo touch foo/bar chmod 400 foo/bar chmod 500 foo Then I can open vim (not as root), edit bar, force a write with w!, and the file is modified. How ...
105
votes
3answers
225k views

How can I replace a string in a file(s)?

Replacing strings in files based on certain search criteria is a very common task. How can I replace string foo with bar in all files in the current directory? do the same recursively for sub ...
4
votes
5answers
2k views

Bash Script to Sort Files into Alphabetical Folders on ReadyNAS Duo v1

I have an old ReadyNAS Duo v1 (Sparc) running an unknown flavour of Linux. I have a folder structure with 1,000+ files I want to move into a folder structure based on the first letter of the file ...
2
votes
3answers
92 views

List transient files by numerical value having number greater than a given constantly varying filename

I've a directory having constantly changing filenames (by numerical value) listed as: -rw-rw----. 1 root root 10493952 May 7 10:39 A0000000.LOG -rw-rw----. 1 root root 10493952 May 7 08:38 ...
1
vote
3answers
75 views

Is there a way to undo a terminal command?

I just copied a whole directory into another one using cp ~/local/* ./ and actually wanted to type cp ~/local/srl* ./ so I'm founding myself with a lot of unnecessary files. I can suppress them ...
2
votes
3answers
39 views

Difference between files in directory

I have two directories with same files but with some difference in their contents. I want to list down those files which are differing. For example There are two folders Folder1 and Folder2 with ...
2
votes
1answer
28 views

Merge text files with 1st column and difference in output file

File 1: (text1.txt) Row_Added_Ts Count 01/01/14 2022448 02/01/14 8345155 03/01/14 8663852 04/01/14 6785739 05/01/14 5279913 File 2: ...
-1
votes
1answer
14 views

save output into a file from sqlplus query in ksh script

The thing is that it overwrites in Result.txt and I only get the last query. How can I fix this? #!/bin/sh while read -r line do echo "'$line'" sqlplus -s whatever/whatever <<-EOF SPOOL ...
0
votes
2answers
28 views

Wrong zip command messed up my project directory

I've issued a command gzip -r project.zip project/* in projects home directory and I've messed things up; every file in project directory and all other subdirectories have .gz extension. How do I undo ...
3
votes
2answers
103 views

tar command - skip symlinks

I use the tar command as, tar -cvf protTests.tar protTests/* to tar all files inside the folder, protTests. But this is including the symbolic links inside the folder, which is not a desired one. ...
1
vote
2answers
22 views

No option of creating new file in centos 7 gui [duplicate]

I have recently installed centos 7 and was trying to create a new file through right click and selecting create a new file option as I have done in centos 6 but there is no option of create new file ...
1
vote
1answer
24 views

Detecting file size and do operation conditionally

In my main_dir, I have a lot of sub-folders say DFT1 to DFT150, and in each directory, there is a file named OSZICAR. However, some of this would have file size 0. So I would like to have a script, ...
-1
votes
0answers
19 views

Can't locate Vim folder anywhere on linux mint system

I'll try to keep this short. I've been trying to install YouCompleteMe and have had a bunch of trouble, so consequently I have installed and uninstalled vim a few times. Now my problem originated ...
40
votes
2answers
3k views

why is rm allowed to delete a file under ownership of a different user?

From the post Why can rm remove read-only files? I understand that rm just needs write permission on directory to remove the file. But I find it hard to digest the behaviour where we can easily delete ...
0
votes
0answers
22 views

how to exclude specific subfolder when creating zip file via command line linux

I do want to exclude subfolder like uploads/2015/OtherSubfolderName through command line. I have tried with below command, its working fine. zip -r zipfile.zip public_html -x *uploads* but can we ...
0
votes
3answers
32 views

Backing up files [duplicate]

I would like to backup all files older than 90 days and greater plus gzip them. I could execute: find /path/to/files -type f -mtime 90 -exec gzip "{}" \; Problem with this command is it includes ...
1
vote
1answer
62 views

How to know which programs support streaming I/O

As I understand it, programs that support streaming I/O can work with files more than the size of the memory. Is this correct? Is there a way to know which programs support streaming I/O?
11
votes
5answers
32k views

Add lines to the beginning and end of the huge file

I have the scenario where lines to be added on begining and end of the huge files. I have tried as shown below. for the first line: sed -i '1i\'"$FirstLine" $Filename for the last line: sed -i ...
0
votes
0answers
19 views

Lubuntu won't let me change a file's permission

Yesterday I installed Lubuntu, and it works great. Today I've been messing around with my files (don't worry they aren't system files) and I came across file settings (keep in mind that I am the Admin ...
6
votes
6answers
35k views

How to transfer files from Windows to Ubuntu on Virtualbox?

How should I transfer files from Windows to Ubuntu installed on Virtualbox? When I plugged in a USB, it only pops up in Windows. How can I see it in Ubuntu?
0
votes
1answer
582 views

Bash script, ask for user input, to change a directory, sub directorys, and file's mtime atime linux recursively

Using GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) I am a bash scripting novice, not sure where to begin except at shebang #!. The following command. touch -a -m -t 201501010000.00 ...
3
votes
1answer
30 views

Using File Date/Time as Metadata: Reliable?

Background: I have groups of files in their own directory which I merge into one file in order of their filename. I call them t1.txt, t2.txt, t3.txt... I merge them in order of the integer. ...
5
votes
2answers
27k views

Cron job to delete files older than 3 days

I need to remove files older than 3 days with a cron job in 3 different directories. (these 3 directories are children of a parent directory /a/b/c/1 & /a/b/c/2 & /a/b/c/3) Can this be done ...
0
votes
3answers
46 views

Rename files in directory according to name of directory

I am trying to rename a bunch of files according to the names of their directory in Linux, SSH. I have a directory called XYZ01smith. In it are four files called smith_5*.I need to add prefix XYZ01 ...
-4
votes
1answer
26 views

How can I show the size of all cache files in my home directory? [closed]

I want to get the size of all cache files in the home directory.
1
vote
1answer
28 views

Check if multiple files exist in directory

How to find multiple files present in a directory in ksh (on AIX) I am trying below one: if [ $# -lt 1 ];then echo "Please enter the path" exit fi path=$1 if [ [ ! f $path/cc*.csv ] ...
9
votes
3answers
522 views

Find all animated gif files in a directory and its subdirectories

let's say that i've done a find for .gif files and got a bunch of files back. I now want to test them to see if they are animated gifs. Can i do this via the command line? I have uploaded a couple ...
2
votes
3answers
93 views

FNR and NR variables problem

I have two files, one of them has 10 records, and the other one with 15 record, the problem is when I cat them together, always FNR=NR. For example, consider below files: File1: 1,boo 2,foo 3,boo ...
48
votes
2answers
25k views

Why can rm remove read-only files?

If I create a file and then change its permissions to 444 (read-only), how come rm can remove it? If I do this: echo test > test.txt chmod 444 test.txt rm test.txt ...rm will ask if I want to ...
-1
votes
0answers
11 views

How to downgrade a package in Xubuntu 15.04

I want to install Skype in Xubuntu 15.04 and it does not work. Someone suggested that: Here is the fix: Downgrade. Enter the following into terminal. sudo pacman -U ...
0
votes
1answer
61 views

SED - Find and replace with special characters (#, , % )

I'm aware that this is a really simple question, but I'm struggling to find a solution to this . I need to automatically find and replace in the /etc/aliases file the following section: # Person ...
3
votes
1answer
31 views

How to limit speed of file copy?

I am copying huge file from NFS mount using dd: dd if=/mnt/nfs/image.img of=/dev/sda I need to limit the speed of reading from NFS. How can I achieve it? The only precondition is to use some easy ...
12
votes
4answers
379 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, ...
1
vote
1answer
43 views

Batch renaming of files with ascending number

I have a batch of files: $ ls Li1Fe1O2_11 Li1Fe2O3_8 Li1Fe3O4_2 Li1Fe3O4_5 Li2Fe1O3_16 Li2Fe2O4_12 Li3Fe1O4_19 Li3Fe1O4_22 Li1Fe1O2_14 Li1Fe2O3_9 Li1Fe3O4_3 Li1Fe3O4_6 Li2Fe1O3_17 Li2Fe2O4_13 ...
6
votes
4answers
13k 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?
4
votes
3answers
574 views

Find files in directory with paired names

I'm running tests of a variable-size-and-contents test set. Data files are added and removed frequently. I'm looking for an automated way of gathering a file list. All files are in subdirectories of ...
5
votes
3answers
83 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 ...
0
votes
1answer
13 views

How to use tune2fs?

I want to adjust the time interval between ext2, ext3 and ext4 filesystem checks to 180 days? I know that I have to use tune2fs -i 180 but I am not sure about the arguments
4
votes
1answer
38 views

Reason for change in ctime when the file content is modified

I understand that ctime changes when the file metadata or the file content is changed and mtime on file content modification. I would like to know the reason for updating ctime when the content of ...
0
votes
1answer
20 views

How do I check whether audio file samples are clipped without playing the file?

I have a big MP3 audio file, about 170 MB, which I'd like to check for clipping. In details I need to increase the audio volume but I don't want to push the volume too high and clip audio samples. I ...
1
vote
0answers
29 views

What exactly files whose names' prefix is “AT.postflight.” are needed for?

I am not sure if this question should be asked here, since I am on an OS X, but since I am using bash, and I am asking about the meaning and the purposes of some files. I am trying to understand why ...
-2
votes
3answers
50 views

Delete subdirectory folder while saving contents

Lets say I have the directory /Users/admin/Documents/Folder1/file1.txt and would like to delete Folder1 without also deleting file1.txt. In the end it should look like ...
5
votes
1answer
279 views

How to create files named 'a to z' - any trick? [duplicate]

I need to create 26 files named a to z in single command. I thought touch command would be sufficient with the regex, but it doesn't expand [a-z] instead it creates a single file with name "[a-z]". $ ...
2
votes
3answers
46 views

Duplicate a file with random probability

I have a directly full of images and I am trying to put together a script/command that will randomly copy (with some probability) the image to a location with a random name at that destination ...
0
votes
0answers
24 views

Light file copy with diff

Is there a way to copy a file by creating another instance of it that is no created as a hard copy but by a link with the difference that any edit to that file will be saved in an diff file? Like ...
1
vote
3answers
54 views

Find lines in (muliple) files that contain the given line in an input file

So, if I have a number of files like the following: file1: 123 456 789 012 file2: line1 922 line2 392 line3 456 line5 291 line6 201 ... file3: line1 111 line2 123 line3 19 line5 542 ...
7
votes
5answers
85k views

How to create a simple .txt (text) file using terminal? [closed]

I'm just trying to review basic terminal commands. Having said that, how do I create a text file using the terminal only?
5
votes
1answer
39 views

Is it possible to make ls ignore Windows hidden files?

I'm using the GnuWin32 libraries on a Windows 7 machine. Everything is working fine except that the ls command is showing all of the NTFS hidden files. The solutions I've found for this so far all use ...