Questions tagged [files]

Manipulating files: copying, renaming, searching, analyzing, archiving, etc. For operating on text in a file, see /text-processing. For questions about the Files file manager (formerly Nautilus), see /nautilus.

Filter by
Sorted by
Tagged with
0
votes
2answers
54 views

Reshaping tab separated file

I have a file that looks like this: Time Flag 0.65 5.885581e-01 0.56 5.847484e-01 0.58 5.278409e-01 0.57 1.140746e+00 1.00 0 0.00 0 1.00 1 0.00 0 But this is because I ...
0
votes
2answers
2k views

find and replace with the value in another file

I have two files with different formats with columns tab spaced. I have to compare the columns column1, column2 of file1 with file2. If they matches, I need to replace the value in column6 of file1 ...
192
votes
8answers
26k views

Why is looping over find's output bad practice?

This question is inspired by Why is using a shell loop to process text considered bad practice ? I see these constructs for file in `find . -type f -name ...`; do smth with ${file}; done and for ...
0
votes
1answer
85 views

How do I copy a file to the clipboard with the terminal?

I'm aware of how to copy the contents of file: xsel -b < myfile.txt But this is not what I want. I would like something like this: ./file2clip.sh myfile.txt Which would copy myfile.txt to the ...
0
votes
1answer
42 views

Why isn't tail command tracking the changes in a file in realtime? [duplicate]

When I track a file in realtime using descriptor i.e tail --follow=descriptor file_name, it doesn't show the changes made in the file, whereas if i track the file in realtime using name i.e tail --...
0
votes
2answers
64 views

If files are copied from a first volume to a second volume, will the files stay the same?

When I connect the external hard drives to my computer(with FreeBSD or other Unix systems) and copy files from the first external hard drive to the second hard drive, are the files on the second hard ...
1
vote
0answers
38 views

Is there any tool in linux that can monitor two folders in real time?

Is there any tool in linux that can monitor two folders and have the contents of folder a synced to folder b in real time?
0
votes
2answers
36 views

Compare the times of different files using shell script

I have a file with below contents. Here i need to compare the timestamp of HIW.ear in the first line with the timestamp of .jars from the second line and i am running out of ideas on how to do this. ...
0
votes
2answers
46 views

Compare content of two folders/disks (including timestamps,permissions)

I have two directories on two different hard drives and want to check if the content is really exactly the same. From what I read I can use diff -rq dir1 dir2 to check if files are missing or differ. ...
1
vote
2answers
27 views

How do I output the unique lines from a grep pattern match while ignoring other parts of the line?

Suppose I have a file called names.txt, which contains a list of names and corresponding emails of people in the following format: FName1 LName1 <random1@test.com> FName2 LName2 <random2@...
53
votes
4answers
94k views

How to find all binary executables recursively within a directory?

If I use find command like this: find /mydir/mysubdir -executable -type f all executable files are listed (excluding directories), and including executable script file (like script.sh, etc). What I ...
230
votes
19answers
340k views

Efficiently delete large directory containing thousands of files

We have an issue with a folder becoming unwieldy with hundreds of thousands of tiny files. There are so many files that performing rm -rf returns an error and instead what we need to do is something ...
4
votes
4answers
6k 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 &...
6
votes
2answers
4k views

Split a JSON array into multiple files

I have a file that looks like this: [ { "billingAccountNumber": "x", "paymentResponseObject": { "uiErrorDipslayMessage": "", &...
3
votes
1answer
167 views

How to make `du` only include regular files in its output?

I want to list all files in descending order based on disk usage, and have obtained the following commands from this: To list the top 10 largest files from the current directory: du . | sort -nr | ...
4
votes
3answers
118k views

cat /dev/null emptied my log file but size did not change

I'm quite new to Unix. Using Solaris 10 I faced the below issue. There is a large log file with size 9.5G. I tried to empty the file using the below command. # cat /dev/null file_log.txt By doing ...
0
votes
3answers
29 views

Numbering a bunch of files according to the date modified timestamp?

So I downloaded a bunch of documents in chronological order, but I have to copy and edit them, which would change the date modified. I would like to prefix them with a number (001_, 002_...) in the ...
0
votes
0answers
17 views

Graphic file copier with filter

I'm looking for a FOSS graphic file copier that has a filter function, like coping a dir tree removing certain files/dirs. I'm aware of only one actively developed graphic tool for coping files (...
3
votes
1answer
41 views

How to copy a file into another file at a certain position using the command dd?

I want to copy a file of 256 bytes at a certain position into another file of size 2048 bytes containing random data, with the command dd in Linux. The offset I have is 144. I have assumed that bs=1, ...
1
vote
1answer
63 views

Compare first column of a file with value if matched get the record

Can any one help me with the below scenario? I have a reference file has data below: file_id|file_name 1|file1.txt 2|file2.txt 3|file3.txt I have a script which accepts input as file_id and fetches ...
2
votes
2answers
273 views

How is the theoretical maximum file size on filesystems like XFS calculcated?

Documentation for XFS claims its current theoretical maximum file size is 8 exbibytes - 1 byte. However, I am wondering how this calculation was computed? I cannot seem to find discussion of this ...
1
vote
1answer
2k views

How do I transfer images from a Fedora 20 computer to an iPhone?

I have a laptop running Fedora20. I have an iPhone4S. I have installed the software suggested here which allows my laptop to read the iPhone. I connect my phone to the laptop using a USB cable. I ...
0
votes
1answer
28 views

can't stat a file with newline in name

I have a file with the following name (I didn't name it!): 'A MULTI BAND MINI PRINTED OMNI DIRECTIONAL'$'\n''ANTENNA WITH V-SHAPED FOR RFID APPLICATIONS.pdf' Weirdness is caused by the '$'\n' in the ...
1
vote
1answer
2k views

Automating dirb for scanning several URLs

I have a bit of a problem making this script work and was wondering if anyone knew what the problem is. It is supposed to take a list of urls as input, scan them for sub directories and then output it ...
24
votes
2answers
3k views

What happens when I kill 'cp'? Is it safe and does it have any consequences?

What are the consequences for a ext4 filesystem when I terminate a copying cp command by typing Ctrl + C while it is running? Does the filesystem get corrupted? Is the partition's space occupied by ...
0
votes
1answer
50 views

mktemp creates file in pwd rather than in /tmp

Previously mktemp used to create files in /tmp. Today I noticed that mktemp is creating file in $PWD rather than in /tmp? Did I change something inadvertently? Any suggestions to fix this? Note: I ...
4
votes
1answer
2k views

Is there a way to view a list of timestamp history of a document/file via terminal/command line?

This seems like it's simple but for some reason, it's not: Problem: I've been writing a paper- not even a script...just an economics paper- over the last 3 months. I'm trying to determine how much ...
1
vote
3answers
9k views

Unable to delete files through Terminal

More recently, I have been using rm -r /path/to/file to delete files, but when deleting from certain locations, I get the error: override rw-r--r-- root/admin for filename? I have tried entering y, ...
2
votes
2answers
24 views

How to sync between 2 file descriptors to the same file, one for reading one for writing

I have the following code: FILE *file = fopen("testfile.txt", "r+"); int fdfile = open("testfile.txt", O_RDONLY | O_SYNC); const char word[] = "writing to a file ...
15
votes
6answers
54k views

Why does “cat ttyUSB0” not produce output?

I connected an infrared receiver to a USB port ... (the last line of dmesg tells device file) $ dmesg [10496.596063] usb 7-2: new full-speed USB device number 2 using uhci_hcd [10496.751112] usb 7-2: ...
2
votes
2answers
2k views

Editing metadata with bash

I have a bunch of photos(jpeg, bmp, png) that I have arranged in such a manner that the metadata is in html form in a separate file. I would like create some script to read this html file and edit ...
0
votes
1answer
144 views

What is the useage of the “compiled magic file” named on the “file” command man documentation?

Reading the documentation about the Linux file command. I have found this in the magic test description: Any file with some invariant identifier at a small fixed offset into the file can usually be ...
0
votes
0answers
123 views

Moving sparse files

cp not only auto-detects sparse files but also has --sparse=always option. I wonder if mv works with the same mechanism or the safe way for moving sparse files is cp && rm Or is there any ...
13
votes
4answers
12k views

What command do I use to see the start and end block of a file in the file system?

Is there any command that will output the beginning and ending block numbers of any file within the filesystem?
4
votes
1answer
2k views

How to find and delete duplicate video (.mp4) files? [closed]

I have 16,000+ short video clips and there are lots of them that are exactly alike to the human eye, but if you examine very closely you will find that one or the other may have an extra 1 second (or ...
0
votes
2answers
37 views

Search one file to see if it contains information from another file

I have two files. The first is unip.txt and the second is ipex.txt and each file contains IP addresses. unip.txt: 49.235.113.205 50.115.166.136 51.15.70.104 51.15.87.74 51.15.134.103 146.148.13.9 148....
0
votes
1answer
33 views

Unix File Protection Commands

~/UnixCourse You should be able to add and remove files from the directory, access files within the directory whose names you already know, and look through the directory via ls to see what files are ...
0
votes
0answers
13 views

Yet another question about recovering lost files (mv, photorec)

Someone that I asked to transfer files for me, transferred some files using mv and something happened. They don't exactly know what, all I know is that the usb stick became full during the operation ...
23
votes
5answers
32k views

How do you compare two folders and copy the difference to a third folder?

You've got three folders: folder current, which contains your current files folder old, which contains an older version of the same files folder difference, which is just an empty folder How do you ...
1
vote
1answer
57 views

Finding text file's encoding

The iconv command may change file encodings. But is there a command to find the file encoding of a certain text file. Also, I am trying to find what file encoding standards each country use. So that I ...
1
vote
2answers
52 views

using rsync (or other tool) to correct file time stamps between two systems

I have two systems (A, B) which have the same file structure. Files are identical but in one of the places (B), the file timestamps are incorrect. The problem is that most of the timestamps in B are ...
0
votes
1answer
44 views

Generate a CSV from select files' directory information

I'm on a mac, and I'm afraid this command line problem has me stumped. At least I'm assuming the easiest way to do this would be through the CL. I'd like to recursively search a directory tree for ...
6
votes
3answers
74k views

need to move files to different folder based on the creation date [duplicate]

I have set of files created from Monday to Friday.. a -- > 08/20 a1---> 08/21 a2---> 08/21 a3---> 08/21 a4---> 08/22 a5 --> 08/23 I need to move only 08/21 file to diffrenet folder....
30
votes
6answers
56k views

Create many files with random content

I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, Name size file1.01 2K file2.02 3K file3.03 5K ...
0
votes
1answer
32 views

Uploading files to remote server and batch rename

I have a large set of files and need to upload them to a remote machine with specific destinations. I have a map (can be re-organised) as 1/1/1/file.jpg -> 2/3/4/image1.jpg 2/12/2/file.jpg -> 5/...
1
vote
1answer
47 views

Editing a file without it being executable

I have a file secretinfo.txt inside a directory SensitiveData that I am trying to edit. Currently, the directory and file have the following permissions: drwx------ 2 www-data root 4096 Apr 20 17:39 ...
5
votes
1answer
3k views

What do these numbers in a 'hexdump' of a file mean?

I created a simple file, 1.txt: echo "hello" >> 1.txt Then I dumped it: hexdump 1.txt And the terminal output: 0000000 68 65 6c 6c 6f 0a 0000006 What ...
0
votes
1answer
870 views

lmgrd: No such file or directory

While there are comparable questions out there, I have not found a solution for this specific circumstance. And I admit that this particular question may be appropriate to only me; however, the ...
2
votes
1answer
406 views

Rearrange pdf pages (swap odd pages and even pages)

I have a pdf and I am in need to replace even and odd pages. If I want to be more specific, I must replace (2n-1) page numbers with (2n) ones (1-->2, 2-->1, 3-->4, 4-->3, and the like). ...
0
votes
2answers
31 views

select data conversion based on value range

I have a text file with 3 columns of data. However at random times in the various files there is a change in the in the observed unit from ppn to ppb resulting in the need of a conversion factor and ...

1 2
3
4 5
91