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

learn more… | top users | synonyms (1)

0
votes
1answer
31 views

Mount .img file

I'm trying to mount an img file but I can't seem to do it successfully. When I fun the file command on that .img it returns the following: $ file file.img file.img: data When I try to use mount ...
1
vote
0answers
20 views

trash and restore script - issue restoring

#!/bin/bash echo "Are you sure you want to move this file to the Recycle Bin?" "(Yes/No)" read ans case "$ans" in Yes) echo "$(readlink -f $1)" >> "$HOME/TrashLog" && mv "$1" ...
0
votes
0answers
16 views

editing a document opened by vi in CentOS 7

When I type vi $var_name/pathto/somefile.xml in the terminal in CentOS 7, it opens the requested file as read-only. This is true even though I am using the terminal as root after first typing su -. ...
0
votes
2answers
12 views

moving a file to a folder with root privileges in CentOS 7

I am reading a tutorial that wants me to place a script file called script.sh into a folder called /etc/profile.d/. However, when I try to save the script.sh file in that directory, the gedit tool ...
6
votes
1answer
132 views

Converting sparse file to non-sparse in place

On Linux, given a sparse file, how to make it non-sparse, in place? It could be copied with cp --sparse=never ..., but if the file is say 10G and the hole is 2G (that is the allocated space is 8G), ...
4
votes
2answers
134 views

Is there a way to protect a file from being deleted, but not from being altered?

I want certain files to be able to be altered by myself on my basic account. To me, they are high priority files, with many backups. But we have some young'uns in the house and I don't quite trust ...
-7
votes
1answer
47 views

How to list all file names in terminal?

Let's say I want a list of files in the Downloads folder to be viewed from the terminal. How would I do that?
2
votes
3answers
145 views

How to create multiple files with different names and different extensions?

I'm trying to create some files that has different names and with different extensions. Let say I want to create for example 3 files with following name and extension: File001.000 File002.001 ...
5
votes
3answers
539 views

Shorter command for deleting files

Our web server was originally maintained by a different company. They wrote a short script to clean out cache files. Their file has several lines that read like this: /usr/bin/find ...
0
votes
0answers
16 views

Programatically capturing application inputs and outputs

I've been given a mess of applications that all touch various common files and data sources. (Retail IT environment so lots of generic sources of data that gets sliced and diced into various ways and ...
2
votes
1answer
33 views

Using `stat` to determine filled blocks

How can I find the number of filled block of a certain file, using the stat function? I have already found the command $(stat -c%b "$FILENAME"), which gives the number of allocated blocks but I don't ...
1
vote
1answer
39 views

What is the cause of this error: Error: EACCES, permission denied

I have two three users: db, nr, ba All three are members of the group dbp Node.js is installed in /usr/bin If I run the command : /usr/bin/node /home/db/dbb/m/i.js Then it works fine when I run ...
1
vote
1answer
70 views

How to compare directories with binary files

I'd like to compare directories with binary files. Actually, I'm not interested in what the actual differences between files are, but to know if there's a differ (and what files differ). Previously I ...
2
votes
3answers
50 views

Remove files from listing that are created/modified on Saturday

I am not sure if it is possible. I do ls -l, it gives all the files in the current directory. Is there a way to say list only files that weren't created/modified on Saturday's with shell command?
1
vote
3answers
44 views

How to remove matching files from directory A in directory B in the command line?

I have some duplicate files in directories A and B, how could I delete the dupes in B using the filenames from A in bash? How to do it in other shell's is a welcome bonus.
1
vote
1answer
23 views

Incrementing/decrementing a number in a file from a ( zsh ) script

From a script ( running multiple times simultaneously ), I would like create a file something like: echo "0" > /tmp/count Then I would like to do three functions. incr /tmp/count decr ...
1
vote
1answer
18 views

Automatically pauseing rsync if target is full

I need to transfer 80gb's of unsorted text documents from one computer to another and all I have is a 32gb USB. Is there an option to make rsync automatically pause when the USB is full without losing ...
24
votes
2answers
8k views

I made a mistake last night, which deleted 1800GB of my File-Server unintentionally

I ran this command yesterday, I thought on a test machine, but it was a File-Server connected through SSH. sudo rm -rf /tmp/* !(lost+found) My terminal emulator is Konsole. My system is Debian 7. ...
5
votes
1answer
47 views

List all files that are present in the cache

This question answers to the question on how to find the what is part of cache. However, in the fincore executable you have to pass the filename to check if it is part of cache. Is there a tools or a ...
13
votes
3answers
645 views

Determining if a file is a hard link or symbolic link?

I'm creating a shell script that would take a a filename/path to a file and determines if the file is a symbolic link or a hard link. The only thing is, I don't know how to see if they are a hard ...
3
votes
4answers
71 views

Determining the number of files and subdirectories in Linux

When displaying directories in linux using ls -ld, I get something like this: user@shell:~/somedirectory$ ls -ld drwxr-xr-x 2014 K-rock users 65536 20011-11-05 11:34 user@shell:~/somedirectory$ ...
5
votes
3answers
272 views

How to view last 5 lines from last created/modified file?

Every day I have to take backup and update the status to support teams at particular time for which I need to check last 5 lines of last created/modified *.aff file in a directory and update them. ...
0
votes
1answer
27 views

Check for subdirectory

A)I used the following code to get the modified date of a file. But this is also selecting the subdirectories and thus returning an error. How van I fix this. for file in $1/*; do echo `stat ...
0
votes
1answer
34 views

How to execute genymotion?

I just downloaded an Android Emulator and it downloaded as genymotion-2.3.1_x64(1).bin-- how do I open that? Install it?
1
vote
2answers
40 views

how to I change permissions to all subdirectories except for 1 folder using a single find command?

I need to change the folder and file permissions in all subfolders except for 1 folder. Currently, I'm running several find/exec commands to make it work. e.g. find /mystuff/temp/videos -type d -exec ...
0
votes
2answers
23 views

Can LVM split files between volumes?

Let's say I have 2 volumes 2 GB each (kept as single group). And I would copy there 3GB file. Will it be split? I just hope the answer is "no", and the files are atomic. The reason is -- with ...
18
votes
4answers
1k views

Are Unix Internet sockets files?

I understand that "Everything is a file" is one of the major concepts of Unix, but sockets use different APIs that are provided by the kernel (like socket, sendto, recv, etc.), not like normal file ...
2
votes
5answers
98 views

How to find different files in UNIX based on . extension?

How to find different files in UNIX based extension. Lets say suppose if I have 100 files for each vamsi.log-vamsi100.log, krishna.txt-krishna100.txt, super.csv..., rajat.jpeg..., ...
6
votes
3answers
307 views

how do I remove all files in a folder except just some specified files?

I want to remove all files in a directory while leaving just some specified files, they don't have anything in common by name. How could I achieve that? For example, the file names I want to keep ...
1
vote
1answer
36 views

Delete a directory under Cryptkeeper without access to its account

I have a computer with read-write permissions for one of it is directories. I lost the password that can help me to log in to that directory. How can I delete this folder. I am using the following ...
0
votes
2answers
68 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
1answer
116 views

“bash: cannot create temp file for here-document: No space left on device”

My / only has about 800MB free space left. I guess it is the reason that $ convert * book.pdf Segmentation fault (core dumped) bash: cannot create temp file for here-document: No space left on device ...
3
votes
1answer
22 views

I need to create file with name is the result of the command in Solaris

I need to create only one file with name is the result of the command ls -l | head -2. I can't use environment variables. The filename must contain newline symbols. I've tried to use touch 'ls -l | ...
1
vote
1answer
46 views

File weird character encoding [closed]

I'm on ubuntu 13.10 and am writing a program in eclipse that's supposed to output my result in a file. I'm building an LZW compression and decompression program that uses character conversion to its ...
0
votes
4answers
245 views

keep the last file of every month and delete the rest

I have files like below. I want to keep SEP 30, OCT 30....files and delete the rest. Can you please help me with any script? -rw-r--r-- 1 nbswmcm advboprd 13463761 Sep 2 01:19 ...
1
vote
2answers
64 views

React to incoming files in a directory on HP-UX

How can I achieve this logic using a script: Monitor new incoming files in a directory. If files are not received in the directory for 3 hours or if the received file is empty then do something. ...
6
votes
4answers
572 views

Modify a file without creating another file

Is there a way to modify a file without writing the contents to other file, without sed and awk? For example, $ cat test.txt aaa aaa bbb ccc ddd Replacing using sed with -i option, sed -i ...
2
votes
1answer
44 views

Maximum time a file descriptor can be held

I am writing a long-running program in the Linux environment that will be calculating entries in a large table. Every time it comes to the end of the row, it outputs the calculated values into a ...
1
vote
3answers
33 views

Why does Debian prefer a temp file replacing the original over modifying bytes in original file?

In the mp3gain manpages, you can read the following: -t mp3gain writes modified mp3 to temp file, then deletes original instead of modifying bytes in original file (This ...
-3
votes
0answers
55 views

7z command for files larger than 4GB ( unzip doesn't work) [duplicate]

My unzip command doesn't work for files that are greater than 4GB. Consider my file name is unzip -p -a filename.zip, the command doesn't work since the size of the file is larger. I need to know the ...
2
votes
5answers
117 views

Finding new lines in one file compared with another

I need to compare two txt files. Every line of both txt files contain entries. One entry per line. The new file contains entries the old one lacks. I have tried to use diff and vimdiff but these don't ...
4
votes
1answer
39 views

rsync doesn't preserve directory ownership even with -a

I use this rsync invocation to backup my home directory: rsync -aARrx --info= --force --delete --info=progress2 -F "$USER_HOME" "$BACKUP_MNTPOINT" rsync man page says that -a implies -g and -o ...
1
vote
1answer
24 views

Postfix no longer logs to /var/log/mail after it has been deleted and re-created?

I accidentally deleted the /var/log/mail file. Until that point I was able to monitor it using postfix stuff. Now, it seems that Postfix doesn't send its logs to /var/log/mail, since the file is not ...
0
votes
1answer
61 views

Why the size of an empty directory in Linux is 4KB? [duplicate]

I'm using Ubuntu 14.04 and I made an empty directory on /tmp with the mkdir command: cd /tmp mkdir foo and then I checked it's size using ls: ls -ldh foo and the result shows that the size of ...
1
vote
0answers
32 views

open() sys call [closed]

Process A wants to open a file fd1 = open("/var/file1", O_RDONLY); In the process of opening file1 which table is referred first system wide file table or file descriptor table or in-core inode ...
4
votes
3answers
110 views

Add text with echo but start with new line if file not empty

I'm trying to create next script echo "#!/bin/sh" >/script echo "del x.txt" >>/script witch is ok if /script file is empty, if not - will append first line to last text #!/bin/sh del ...
3
votes
3answers
78 views

How to use all the inodes

Without creating a file can I use any inode which is free? I want to write a script that will use all free inodes in the system. is it possible?
1
vote
3answers
75 views

Find and delete duplicate txt files

I have a folder with around 300 text files, is there any command that reads every every file indivdually and deletes the duplicate files? I mean the content and not the file names.
0
votes
0answers
22 views

Change encoding of a text file in-place: iconv alternative? [duplicate]

Apparently, iconv is unable to use the same file as input and output file. Other tools, e.g. sed, have an -i switch that allows "updating" a file in-place. (Under the hood, temporary files are ...
2
votes
1answer
65 views

How do I choose a file names with consecutive numeric suffixes?

I like to preserve things, so I want to preserve .bash_history. I would like to copy it into a directory using a script. Like here #!/bin/bash #Something here? number=~/Desktop/Coding/Bash\ ...