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

learn more… | top users | synonyms (1)

0
votes
3answers
39 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? [on hold]

I want to get the size of all cache files in the home directory.
1
vote
2answers
23 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 ] ...
8
votes
3answers
501 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
88 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 ...
44
votes
2answers
24k 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 ...
2
votes
2answers
36 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
votes
0answers
10 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
50 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
30 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
375 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
36 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
559 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
37 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
17 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
23 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
49 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
272 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
81k 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
38 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 ...
1
vote
2answers
186 views

What files does the Linux kernel access?

/init during early userspace, /sbin/init, and /sbin/request-key are three files that the Linux kernel accesses (and they are all executables). Are there any other files, possibly non-executable ones, ...
0
votes
1answer
2k views

Setfattr always returns operation not supported

I'm trying to get a script working however I'm having issues with a particular line trying to set file attributes with setfattr. The line in question is ret=os.system('setfattr -n "user.dummy" -v ...
14
votes
10answers
19k views

How to move 100 files from a folder containing thousands?

I have a directory with thousands of files. How can I move 100 of the files (any files will do) to another location.
18
votes
5answers
13k 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?
1
vote
0answers
35 views

Detect and remove unused files to save space [closed]

I want to save disk space by removing files I don't need. BleachBit crashed systematically when running in my Ubuntu 14.10 machine. However, what can I run as command to clear temporary files, broken ...
2
votes
0answers
45 views

Can file handles be translated to filenames?

Is there a tool for translating file handles to file names on Solaris 10? I've looked around and found several scripts including the one at: http://heim.ifi.uio.no/kjetilho/hacks/fhfind.perl ...
1
vote
1answer
48 views

Does linux have file locking protection when trying to rename/deleting files

I have a cron job that kicks off a new process every day. The process runs every 5 minutes and appends to a log file. Another cron job runs every 60 minutes. It takes some of the data in the log ...
1
vote
0answers
18 views

Write shrunken .img file to device file

I have a backup image of a device file /dev/sda3 that I created using: dd if=/dev/sda3 of=~/sda3.img. The image is very large, so I have re-sized it to remove empty space. My question is can I ...
2
votes
2answers
44 views

File contents created when opened

Basically what I want is this: Having a file called file somewhere in the filesystem whose contents are something like: #!/bin/whatever-interpreter-you-want echo 'line1' echo 'line2' So, when ANY ...
0
votes
2answers
54 views

Rename the bunch of files with a specific pattern

I have number of files with following name details.. 2007-07-22-2300-11S.NAN___024_ABI___HH_E_SAC Where: 2007-07-22 is date. 2300-11S is hhmm-sec. NAN___024 is network same for each file (not ...
0
votes
2answers
36 views

Why do compiled programs create a copy with ~?

Why is it that when I run programs for the first time it creates a copy of that file with a ~ at the end? For example, a file like HelloWorld.lua when run would create 2 files: HelloWorld.lua and ...
2
votes
6answers
5k views

Find files by the length of filename

I want to find all files by length of the file names. For example if I want to find files of length 1, such as a.go, b.go I put: grep '.\{1\}' file But this does not work. What command can I use ...
1
vote
3answers
55 views

Merge several files on the basis of the md5sum

I have a file data.txt, which was divided into fragments. I need to properly combine fragments of files so that the original file was created data.txt. I do not know what kolejoności do this, because ...
7
votes
2answers
531 views

How to replace spaces in all file names with underscore in Linux using shell script?

I tried following shell script which should replace spaces from all xml files for xml_file in $(find $1 -name "* .xml" -type f); do echo "removing spaces from XML file:" $xml_file mv "$xml_file" ...
3
votes
3answers
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 ...
6
votes
5answers
2k views

Transform a directory into file or a file into directory

I wanted to create a file named test. Accidentally I run mkdir test instead of touch test. Is it possible to convert test directory in a file named test? What about converting a file named test into ...
1
vote
4answers
65 views

Bash Command Get Data from multiple files and append the file name

I have in a folder (eg /tmp) the following files 1.id 2.id 3.id 4.id so on... In these files, there is one number inside. For example in 1.id it can be the 1000, in 2.id it can be the 2000 etc. I ...
5
votes
2answers
78 views

Allow owner to create & read files, but not modify or delete

I would like to give a user permissions to create and read files in a particular directory, but not to modify or delete files. If the user can append to files that is ok, but I'd rather not. This is ...
1
vote
3answers
178 views

How to add an attribute in a tag in XML file by command-line?

I am trying to add field at the end of tag using sed script. Suppose I have a tag in XML file: <book name="Sed tutorial" price="250"/> Now I want to add field as Book_Width="A" after end of ...
16
votes
6answers
1k views

How to corrupt an archive file in a controlled way?

I wrote a function that checks for a corrupted archive using a CRC checksum. To test it, I just opened the archive and scrambled the content with a hex editor. The problem is that I do not believe ...
0
votes
1answer
22 views

Get total size of a list (containing HTTP links)

I have a file containing a list of files on the web, and I would like to know the total files' size (in human-readable format) and check their availability. Is there a command/solution to do so? P.S. ...
4
votes
2answers
93 views

Adding column based on matching of second column

I have two files. The first file has the following format: 10D0325 2465 0 0 -9 -9 10D0598 2567 0 0 -9 -9 10D0562 2673 0 0 -9 -9 10D0175 2457 0 0 -9 -9 10D0241 2209 0 0 -9 -9 10D0954 2312 0 0 -9 -9 ...
1
vote
2answers
63 views

Copy Single Value from a file to a variable and perform arithmetic over it? [duplicate]

Suppose we have a file like 'abc.txt' which has a single value 123456 and file 'xyz.txt' which also has a single value like 654321. I want to store these values form the file to some shell variable ...
10
votes
5answers
25k views

How do I append text to the beginning and end of multiple text files in Bash?

I have a directory full of text files. My goal is to append text to the beginning and end of all of them. The text that goes at the beginning and end is the same for each file. Based on code I got ...