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

learn more… | top users | synonyms (1)

4
votes
1answer
366 views

How to rename all files and add image size to file name

I can`t make this work. I have a lot of images and i want to rename his name and append image size to name using exiv2 exiv2 pr * prints all info about file # exiv2 pr 9b523e5a002268fe5067a928 File ...
3
votes
2answers
191 views

Append timestamp of last edit to filename

I would like to add the time of the last change to the file to its filename using the bash. For example this output of ls -la: -rw-rw-r-- 1 beginner beginner 5382 Dec 1 17:18 B_F1-1.xml should ...
1
vote
2answers
37 views

Why doesn't my regex work in bash “if”? [duplicate]

Here is my code: if [ -f /Applications/xml[0-9].pl ] I also tried with -f =~ and double brackets but none seem to work. I first though that the regex might be faulty but I tried this. echo h1 | ...
3
votes
2answers
835 views

Perform commands on selected items in Midnight Commander

How can I perform a command on the selected items ? for example calling vim, or gimp for the 5 text or image files selected. I tried to make use of the inlined command line at the bottom, but it ...
1
vote
1answer
60 views

Shell script check if file exists?

I wrote a simple backup script which back ups my stuff on a remote server, everything is working great but I'd like to have some sort of report like "backup successful or not". this is my script # ...
2
votes
3answers
55 views

Find files that have a confirmed duplicate in same directory recursively

Say I have the following directory structure: root |-- dirA |-- file.jpg |-- file-001.jpg <-- dup |-- file2.jpg |-- file3.jpg |-- dirB |-- fileA.jpg |-- ...
1
vote
2answers
34 views

Map reading/writing a file to getting output from/sending input to a script?

Suppose I have two scripts, script1.sh and script2.sh. I am wondering if there is a way to make a filesystem interface such that, for example, I can go vim file and then have my system run script1.sh ...
4
votes
1answer
760 views

Samba set share browsable only for a group

How I can configure samba to set browsable a share for a group only. I wanna hide the share for all other users, if a set browsable to yes all the users can see the share when explore. I don't want ...
1
vote
4answers
186 views

How to delete the files in one folder which are more than 60 days old in UNIX?

I know how to delete the files which are more than 60 days old by modification time, but I want to delete files based on a timestamp in the file name. For example, I have the below files for each day ...
1
vote
1answer
133 views

File of Doom freezes any computer that attempts interaction

I have a file on an internal server that causes any machine that interacts with it to immediately and irrecoverably freeze. By interaction, I mean just about anything: rm, mv, cp, cat, vi, gedit, ...
1
vote
3answers
74 views

How to hide a content of a file? [closed]

Is there any way to hide the content of a file? Suppose I have the file bind which contains the following line: This is a test. After saving the file, it should not display its content. Is there ...
0
votes
1answer
48 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
35 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
2answers
42 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
175 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), ...
-8
votes
1answer
52 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
177 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 ...
3
votes
4answers
440 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 ...
5
votes
3answers
554 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
18 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 ...
4
votes
1answer
42 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
66 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 ...
2
votes
1answer
35 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
96 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
62 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?
17
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 ...
11
votes
3answers
5k views

Pseudo files for temporary data

I often want to feed relatively short string data (could be several lines though) to commandline programs which accept only input from files (e.g. wdiff) in a repeated fashion. Sure I can create one ...
1
vote
3answers
52 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
29 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 ...
8
votes
4answers
11k 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 ...
4
votes
3answers
522 views

How to know if a text file is a subset of another

I am trying to find a way to predict if a text file is a subset of another.. For example: foo bar is a subset of foo bar pluto While: foo pluto and foo bar are not one a subset of each ...
5
votes
1answer
57 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 ...
1
vote
1answer
22 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 ...
12
votes
3answers
729 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 ...
5
votes
3answers
287 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
76 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?
3
votes
4answers
83 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$ ...
0
votes
1answer
34 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 ...
2
votes
2answers
104 views

How to disallow file modification time change for non root users

I don't want anybody to create a file then change the creation date to backward date(For example using touch or system call). In my Ubuntu hosting account I'm getting many hacked php code getting ...
1
vote
2answers
87 views

List files based on the date and time in the file name

I want to automate one task in UNIX and make one script. There is a directory in which everyday 2 files come and that files come anytime in between 10pm to 1am. The file name is something like ...
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 ...
12
votes
3answers
20k views

File extensions for unix shell scripts

On wikipedia, the article for .sh says: For the .sh file extension type, see Bourne shell. How about other unix shells? I know that the shebang is used inside the file to indicate an ...
1
vote
2answers
58 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 ...
2
votes
5answers
110 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
335 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 ...
0
votes
2answers
113 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
1
vote
2answers
75 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. ...
1
vote
1answer
41 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
1answer
536 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 | ...