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

learn more… | top users | synonyms (1)

1
vote
2answers
45 views

assigning read/write privileges for a folder to a user in CentOS 7

I am logged into a CentOS 7 server as root. I created a folder /somefolder. I want someusername to be able to write to that folder via scp from a remote computer. What command should I run so that ...
2
votes
1answer
28 views

Linux Mint desktop displays different files from ls command

Background I'm running Linux Mint 17 Cinnamon. After a botched attempt at migrating my data to a NAS, I restored my data from an external USB. Problem Statement After restoring from backup, all my ...
5
votes
2answers
47 views

Merging/Combining 2 text files according to numeric field

I have 2 text files file_1: 14595|Age 35|Salary xx|Position ax|2013|Info 1|Info 2|Info 3|Info 4|Info 5 14649|Age 30|Salary xx|Position az|2015|Info 1|Info 2|Info 3|Info 4|Info 5 file_2: ...
1
vote
2answers
19 views

May cp override subdirectories with the same name?

I downloaded an Adobe flash plugin, It includes a .so file and a directory called usr. In this folder, it has sub-folders like bin, lib, lib64, share. In the readme file, it says I need to do the ...
0
votes
0answers
4 views

QMMP player takes over file-manger association in Manjaro Linux

Sometimes Firefox gets associated with a different file manager than the one it is supposed to. But now it got associated with a media player instead of a file manger; a very odd behaviour in Manjaro ...
1
vote
1answer
33 views

Special character filename

I have to create such filename, so I can try one pipeline but I am not quite sure how it would happen. So the file's name(s): ;rm *;.jpg (or ;rm -rf *;.jpg). The format of the file doesn't matter, I ...
1
vote
0answers
18 views

run a certain file (e.g. a .py) when a certain image, .wav or excel file get opened [duplicate]

Recently, me and my friend have purchased a Palm Vein Scanner. the goal was using it in a mini-project as a new door lock system. we are connecting it to a Raspberry Pi to run the software on it. ...
2
votes
1answer
44 views

How to count occurrences of all the words in all the files of a directory using grep? But with count incremented only once per word per file

I have already asked a similar question but people misunderstood what i was asking. I was asking how to generate a list of every word with a word count incremented only once per word per file. For ...
2
votes
3answers
48 views

Find command associated with configuration file

Let's say I didn't know what ~/.bashrc is for. Is there a command that would tell me what the file is/does? Other than googling for an answer. The man pages have a files section, maybe there is a way ...
0
votes
3answers
47 views

Number of files in a directory starting with specific text

How to get count of files in a directory starting with specific text like dataxxx.csv
-1
votes
2answers
134 views

delete files having a certain pattern in their names

I want to delete all files that have two numbers and a dot in beginning of their names for example: 01. abc 02. xyz
1
vote
2answers
74 views

How to rename file in bash script one by one

I have loads of files which look like this: data1.csv data2.csv . . data(n).csv My use case is that when I will call my script it will change data1.csv to data.csv and remaining files as it is and ...
1
vote
1answer
20 views

How do I find/list all files on filesystem with a certain SELinux “fcontext”

I'm having trouble finding information on what command, presumably from setools, I should use to find all the files on my filesystem that are labeled by SELinux with a certain file-context (fcontext). ...
6
votes
4answers
153 views

Need to move the last line of the file to second line of the same file

I have a file 'test' in linux with below data. aaaaaa bbbbbb cccccc dddddd eeeeee I need to cut the last line of this file and put it in the second position. It must look like below. aaaaaa eeeeee ...
0
votes
1answer
34 views

Split the large files into sub files. How to do this process? [duplicate]

I have a large file in my unix box with 2 Gb. The files contains the xml lines. I want to split the files into say 10 files say each file is now of 204 MB ( approx ) so that combining the 10 files ...
2
votes
2answers
57 views

Check files for conventions

I need a script that checks and lists all text files for project conventions. With conventions I mean for example: UTF-8 encoding No trailing white spaces Newline at the end of file No not-ascii ...
6
votes
6answers
1k views

How can one run a program installed in one machine from another machine?

Is it possible to have, say, one machine with software installed and call that software from another machine? I thought this would be called an "application server" but by googling I find things that ...
1
vote
1answer
47 views

How to give permission to group to read/edit unowned files on archlinux?

I'd like to be able to read files from external hdd or other partitions without having to su root every time or chmod the whole partition to myself/group. How can I give myself/group permission to ...
2
votes
2answers
47 views

Deleting files older than a month [duplicate]

Need to delete all sub-directories which are a month old. But last day of the month data should be ignored for previous three months. The data representation is as follows: bkp_01102014 ...
0
votes
0answers
26 views

How to compare file sizes in two directories?

I have copied some files to an SFTP-only server. I want to verify that all the files arrived intact. Since the server is SFTP-only, I cannot run e.g., an MD5sum on the remote host. I have the server ...
1
vote
2answers
41 views

Convert a hardlink into a symbolic link

It is easy to convert a symlink into a hardlink with ln -f (example) It would also be easy to convert a hardlink (filenames link and original) back to a symbolic link to link->original in the case ...
2
votes
1answer
26 views

Remove created file after x minutes

I have a directory /my/path/tmpimages. Whenever a file is copied/created there, add a timer that remove that file after x minutes. What I found is that I need to use inoticoming or incrond to watch ...
0
votes
5answers
44 views

Is there a way to do a “full file buffering” inside a chain of piped commands?

Very often I do simple operations on a file, for example: cat file1.txt|sed -r 's/^ *//' to remove spaces at the beginning of the line. If I want to overwrite the file, the only way I know is: cat ...
1
vote
0answers
20 views

How can I set a group policy to all access on all folders except one?

I am currently making a test environment where users will be going through a network administration course with different levels they must complete. Due to the nature of the course, we want to give ...
2
votes
3answers
65 views

Is it possible to detect when a file has been downloaded?

We have a server where another script sFTPs and downloads files everyday. Question: Is it possible to detect that the file was downloaded and then for me to automatically archive the file after they ...
-1
votes
2answers
44 views

How to find a file on Windows in linux using the terminal

I have a .java file in Windows that I need to access in linux because it is a requirement of a homework project of mine to submit it to the school's linux server. In the past, I've copied and pasted ...
1
vote
1answer
33 views

batch-rename all config file endings to conform to apache 2.4

since apache 2.4 all files in /etc/apache2/sites-available and sites-enabled have to be named with the ending .conf Now on my server I have a lot of these files, renaming the files in sites-available ...
0
votes
2answers
32 views

Change file hard link count

On my Linux machine, I have the following file: drwxr-xr-x 2 jsgdr Unix_31 4096 Dec 2 17:46 jsgdr How to change the permission 2 to 4 so that I will this: drwxr-xr-x 4 jsgdr ...
1
vote
0answers
24 views

Dynamic ~/.ssh/config

I'd like make my ~/.ssh/config file dynamically generated by a shell script (or anything else that prints to STDOUT). Is there a UNIX trick to make reading a file result in executing a command & ...
1
vote
0answers
52 views

Unable to access a directory despite belonging to a group with write permission [duplicate]

I am learning basic file permission in Linux and tried actions below. I have a folder "music" to which group "music" has wxr permission. I have user "finxxi" added into group "music". When user ...
0
votes
2answers
49 views

linux + find command with rm -rf

why the following command removed the tmp directory under /var and how to avoid this? find /var/tmp -type d -ctime -1 -exec rm -rf {} \; pwd /var/tmp [root@linux /var/tmp]# find /var/tmp -type ...
1
vote
3answers
46 views

Remove old directories according to directory's name?

In my bash script I create a directory each month for backups as follows: DAY=$(date -d "$D" '+%d') MONTH=$(date -d "$D" '+%m') YEAR=$(date -d "$D" '+%Y') mkdir -p /var/app/backup/$DAY$MONTH$YEAR ...
3
votes
2answers
190 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 ...
2
votes
2answers
43 views

Command to work on all files in a folder and output result to single file

I have a list of files, 10 to be exact, in a recipe folder. I must determine the number of occurences of each word in all the files and then order them according to these frequencies. I can get my ...
1
vote
2answers
36 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 | ...
5
votes
1answer
128 views

How to make a list generated by md5deep in alphabetical order of relative paths?

If I want make a md5sum list recursively, then I would use md5deep, but it starts to pop up some problems such as it won't generate the md5sum file in alphabetical order. For example, $ cd ...
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 # ...
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 ...
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
4answers
182 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
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
37 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 ...
1
vote
1answer
39 views

How to change double hyphen to single hyphen of file names?

I have been using the rename command to get control over my naming conventions across my system. In converting spaces in file names to hyphens, I have inadvertently created consecutive hyphens in some ...
6
votes
1answer
173 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), ...
6
votes
3answers
173 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
50 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 ...
5
votes
3answers
553 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 ...