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

learn more… | top users | synonyms (1)

4
votes
2answers
8k views

executing binary file: file not found

I know there are similar questions out there, but I haven't found a solution nor this exact case. The binary was built on Arch Linux using its GCC 4.7. The package works fine on the build system. The ...
1
vote
1answer
192 views
+50

Unreadable backup directory on a USB drive

The title pretty much sums it up. I was editing a script I wrote some time ago to automatically backup the contents of my Raspberry Pi SD card, and in the course of editing, I missed a "/", and so ...
19
votes
2answers
66k views

Where are Apache file access logs stored?

Does anyone know where file access logs are stored, so I can run a tail -f command in order to see who is accessing a particular file. I have XAMPP, which is an Apache server installed on my machine, ...
0
votes
1answer
17 views

Deleting a file object from a library

I've created a library with 3 file objects using: ar rv arhiva.a file.o file2.o file3.o Why I can't delete a file object from it? I've used ar xv arhiva.a file.o
25
votes
6answers
33k views

How to find creation date of file?

I want to find out the creation date of particular file, not modification date or access date. I have tried with ls -ltrh and stat filename.
1
vote
2answers
51 views

readlink -f not working on multiple files

I tried to run readlink -f on multiple files by using wildcard "*", but it evaluates other files as operand Command readlink -f *log Output (desired) /home/trail_1.log /home/trail_2.log Am I ...
1
vote
1answer
33 views

Rename files based on directory names

How can I rename .jpg files in multiple folders based on the name of the folder? I also want the .jpg files to remain in their respective folders and not moved. The folder names have no spaces. So, ...
9
votes
5answers
729 views

How to get the last N files in a directory?

I have many files that are ordered by file name in a directory. I wish to copy the final N (say, N=4) files to my home directory. How should I do it? cp ./<the final 4 files> ~/
8
votes
5answers
3k 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: ...
7
votes
4answers
4k views

Show contents of many files

From the command line, what is the easiest way to show the contents of multiple files? My directory looks like below. ./WtCgikkCFHmmuXQXp0FkZjVrnJSU64Jb9WSyZ52b ...
1
vote
1answer
17 views

output log file from some time to some time via ssh

I have a access_log which size is neally 2GB. I want to analyze it from 2015:09:55 to 2015:09:57, but during this period, there have more than 500 items. So I want to output and download the ...
1
vote
1answer
35 views

How to upload to a unix server?

Im a part of a project group, and one of our tasks is to upload some content to a server. I am completely new to this and have some questions. There are content on different servers(distributed on ...
1
vote
2answers
48 views

Read line from file then delete

How can I read a series of lines from a file and then remove each line? Obviously I can read like this: while read -r line; do echo $line done < myfile.txt But if I do this: while read -r ...
2
votes
3answers
29 views

How to determine if a soft link's target is a directory or a file?

Given the ll command outputs as follows #> ll lrwxrwxrwx ... How to determine if a soft link's target is a directory or a file from "lrwxrwxrwx"?
1
vote
3answers
491 views

In a Bash if condition, how to check whether any files matching a simple wildcard expression exist?

Stupidly, I had been using a condition like this as part of a script: if [ $(ls FOO* 2> /dev/null) ] # if files named "FOO*" were downloaded then echo "Files found" # ... process and ...
2
votes
2answers
25 views

How to remove “lock” from deleted, but still used files on Linux?

SERVER:~ # df -mP /home/ Filesystem 1048576-blocks Used Available Capacity Mounted on /dev/mapper/rootvg-home_lv 496 491 0 100% /home SERVER:~ # SERVER:/home # ...
1
vote
2answers
129 views

multiple conversion bam to bed using bedtools

I have ten .bam files (bioinformatic format) and I would like to convert it to 10 .bed files, but for this conversion I need to use special command bedtools bamTobed -i (input file) > output ...
7
votes
3answers
14k views

Test if there are files matching a pattern in bash

I am trying to write an if statement in bash to test whether there are any files matching a certain pattern. If there is a text file in a directory it should run a given script. My code currently if ...
11
votes
2answers
9k views

how to output text to both screen and file inside a shell script?

Currently I have a shell script which logs messages to a log file like this: log_file="/some/dir/log_file.log" echo "some text" >> $log_file do_some_command echo "more text" >> $log_file ...
-1
votes
1answer
27 views

Show the content of a file in the mail body

I am writing a script where it shows the content of file in the body of the mail. But i am getting error while I am executing it. RECIP="abc@gmail.com" lines=`wc -l $HOME/totals` if [ $lines == 6 ...
0
votes
1answer
15 views

Many files in folder - time difference while accessing file with fullpath

Folder /var/log/something may have 1 file (test.log) in it or 1000000 different files (and test.log of course). Is there a time difference while accessing file test.log with realpath between those ...
3
votes
3answers
85 views

Get modification date that can be used with touch -m

I need to get the modification date of a file so that I can set it on other files using touch -m. stat or perl -le 'print((stat shift)[9])' Didn't return what I wanted. I think that you are supposed ...
1
vote
7answers
176 views

Remove a specific extension from all the files in a directory

I have a couple of files with ".old" extension. How can I remove the ".old" extension without remove the file? I can do it manually but with more work: mv file1.key.old file1.key mv ...
0
votes
1answer
47 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 ...
1
vote
1answer
26 views

Read from character delimted file and assign into variables | for email

I am using ksh. I need to read the data from file, into the variables and then further use them for sending emails. File can be delimited by any less used characters (like | ^ etc.) or group of ...
17
votes
4answers
20k 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 ...
1
vote
1answer
36 views

Chrome too many files open / crash / Sorry Jim

When using Google Chrome I frequently get “Sorry Jim” tabs. The browser also frequently freezes and crashes. Running it from terminal emulator show a long line of Too many open files: ...
12
votes
9answers
12k 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.
1
vote
3answers
41 views

How to access the contents of a file that is used as an argument when running a bash script?

I am running a bash script with its parameters/arguments as files. From inside the script, how do I get the contents of those files? I run the script with this command line: sh script_name ...
3
votes
7answers
577 views

List files whose name begin with any of the characters between a to k

How to list the files whose name begin with any of the character a to k (both inclusive)?
9
votes
5answers
13k views

Find the total size of certain files within a directory branch

Assume there's an image storage directory, say, ./photos/john_doe, within which there are multiple subdirectories, where many certain files reside (say, *.jpg). How can I calculate a summary size of ...
2
votes
2answers
186 views

How to remove all CRLF in file (not replace with LF)

I'd like to remove all carriage returns followed by line feeds (CRLF), such as \r\n in a file. How can I do that? I can't use dos2unix because that replaces CRLF with LF. And I can't use tr because ...
0
votes
1answer
22 views

Recover hard disk file from corrupted one

I bought a 1 TB hard disk from my friend to back up my files but when I tried to copy 150 GB of data to the hard disk, during the last 5MB my laptop shut down due to power loss. After power came back ...
35
votes
2answers
50k 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 ...
56
votes
16answers
16k views

Is there an easy way to replace duplicate files with hardlinks?

I'm looking for an easy way (a command or series of commands, probably involving find) to find duplicate files in two directories, and replace the files in one directory with hardlinks of the files in ...
2
votes
0answers
27 views

Prevent scp from overwriting existing files?

Have been googling this for a while, and the problem is not so much of one where I trust my users to "do the right thing" and have them use rsync with various options to avoid overwriting files. I ...
1
vote
2answers
19 views

Common user to modify files owned by 'other' users

I would like to understand how to use the permission system in CentOS to achieve the following: The system has the following users: user1 user2 user3 And the following directory structure.. ...
0
votes
5answers
61 views

Compare one to one lines in 2 different files using shell scripting [closed]

I have two files: File1 File2 abc abc cde cde,xyz,efg,hij,...,n efg lmn,opq,weq,...n Now I want to compare File1 line1 with File2 line1, line2 with line2 and ...
0
votes
5answers
58 views

Getting the shellscript to display a chosen file extension

I'm new to this with shellscript and Linux and now I'm stuck. I shall write a simple program that allows me to search for andy file extension I want and then display how many of them there are. I've ...
1
vote
3answers
228 views

Constantly check if file is modified bash

I have a file called file1 I want in a script, whenever there is a change in it, do something, a beep sound actually. How do I do that ¿? Thank you in advance
0
votes
4answers
53 views

How does one inspect the directory structure information of a unix/linux file?

In Unix file systems directories are just special files with special directory structures that hold the child filename, filename size and inode reference number. The actual file metadata beyond ...
2
votes
2answers
461 views

Change file timestamp and display hour instead of year with ls

I want to change a file's date to tomorrow 21:00. I used touch, but when I type ls -l the year of the file is displayed instead of the hour. -rw-r--r-- 1 ABCD DEF 0 sept. 30 2014 test01 -r-xr-xr-x ...
5
votes
2answers
10k views

Move files and delete directories with rsync?

Recently I needed to delete a large number of files (over 1 million) and I read that doing: rsync -av --delete `mktemp -d`/ ~/source && rmdir ~/source Was one of the most optimized ways to ...
2
votes
4answers
91 views

Fastest way to read last line within pattern of multiple files with the same extension

I have in a directory /home/files/ some files that all have the same extension .txt. For example 1.txt 2.txt 3.txt 4.txt 5.txt test.txt These files are all the same in data format but the data are ...
2
votes
2answers
1k views

Sphinx Search shutting down after `FATAL: accept() failed: Too many open files`

I'm running Sphinx Search Server V2.06 ( the latest stable release ) on an Amazon EC2 with Linux CentOS. In general it is running fine, but the searchd.log is showing this error over and over with ...
1
vote
3answers
4k views

Changing file associations in GNOME?

This blog post talks about how to change the default application to handle a file type in Nautilus for individual file types (right-click on the file, "open with", and select the new default ...
2
votes
2answers
57 views

How to rename thousands of files efficiently?

I have a bunch of music files (literally thousands of files) in my Fedora PC that I'd like to rename with two rules: Every space must be replaced by the character _ (underscore), and Every letter in ...
2
votes
1answer
44 views

How is the open file table structured?

I'm starting to read Linux Systems Programming, 2nd Ed., and I was curious about the file table that is a "per-process list of open files." Is the file table like a table in a SQL db with the fds used ...
2
votes
1answer
2k views

How do I `avconv` every m4a in a dir to mp3s?

So I'm trying to convert lots of m4as to mp3s, and I think the best way to do that is using avconv. The problem is, I can't seem to find any solid examples on how to use avconv. Looking at the man ...
1
vote
1answer
16 views

What is the difference between these two sets of command for configuring ACL permissions?

Hi I am wondering what is the difference between the two sets of commands below: 1) To allow Davis to access and modify all files and folders in the the home directory of John # setfacl -m ...