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.
0
votes
3answers
38 views
Adding different suffix to end of the line
I have a text file which contains this:
John
Jack
Jerry
I have another text file:
2017
2015
2018
And I want to make them like this:
John2017
John2015
John2018
Jack2017
Jack2015
Jack2018
Jerry2017
...
-1
votes
1answer
32 views
how to list all files with matching permissions of another file [on hold]
I want to write a script that displays all files in a directory with the same permission as file a.txt.
-3
votes
0answers
17 views
SEt file permission in linux from home
I am in my home directory.
I want to set file permission for my file named "Secret" so that no others can read or write this file.
I want to do this by the symbolic method.
0
votes
0answers
33 views
compare and match multiple files by pattern
I need some help with these text files. (fields are separated by commas)
$ cat File1.seed
389,0,
390,1,
391,0,
392,0,
393,0,SEED
394,0,
395,1,
$ cat File2.seed
223,0,
224,1,
225,0,
226,1,
227,0,SEED
...
1
vote
3answers
31 views
Is there a way to know how many processes are opening a file?
Is there a way to know how many processes are currently opening a file in Linux?
1
vote
0answers
24 views
Use rsync to compare a remote directory with a local one, and store differences to another local directory
My problem is similar to the one described in this question. I want to compare a directory to another, and store the differences in a third one. The difference is that in my case the first directory ...
0
votes
1answer
23 views
Rename file name in the loop
I have a loop and I want to select some columns with awk and do sort, and then rename my output file with a new name. My awk and sort are working well, but I want to get a file name with a different ...
1
vote
4answers
48 views
Is it possible to delete a directory in constant time?
I usually remove an entire directory at once with rm -rf. I noticed just now that this takes longer the larger the directory is (reckoned recursively).
Do unix-like systems expose an alternative way ...
3
votes
1answer
14 views
How do I use ag to look for text in files with certain extensions?
I'm using ag version 0.31.0. I can easily look for a string in a bunch of files using:
localhost:workspace davea$ ag 'ftp' .
But what if I only want to scan files with certain extensions? I tried ...
0
votes
3answers
63 views
How do I create a new empty file in a bash script?
I'm running some third-party Perl script written such that it requires an output file for the output flag, -o.
Unfortunately, the script appears to require an actual file, that is, users must create ...
0
votes
1answer
51 views
Why do files sometimes change but not the inode or vice versa?
When a file is updated then the corresponding inode gets updated. But sometimes the following condition occurs
file is same and inode is new
file gets changed but corresponding inode is older
Why ?...
1
vote
2answers
45 views
When is a file freed in an ext file system?
Introduction
Until recently, I thought that on ext file system, inodes have reference counters which count the number of times the file is referenced by a directory entry or a file descriptor.
Then, ...
0
votes
1answer
22 views
File system hierarchy representation
The question is perhaps trivial, but I was wondering about the existence of a command to print the current file hierarchy of my machine. For example:
printhierarchy
root/bin
/boot
/dev
/...
0
votes
1answer
43 views
Where is the file man?
I have a question about the location of the file man, because some people told me it is in /usr/share/man, while other people told me: it's in usr/share/doc.
Where is it?
2
votes
2answers
33 views
When processing input files is making copies/updating and renaming a valid approach?
I have a script that takes as input 2 files.
Before the processing start some preparation is done to the files.
I had the idea to not touch the original files but do everything to copies, print what ...
0
votes
1answer
36 views
What is the full path for the pkill command? [duplicate]
I'm trying to add pkill to my sudoers file, but I think I need the full path for it to not give a syntax error. Does anybody know how to find it?
-1
votes
1answer
23 views
Extract some files from a huge zip file listed in a text file in Linux
I need to extract only specific files listed in a .txt file from a huge .zip file.
I tried:
cat /HGC/list.txt | while read file ;
do
gunzip all_human_gene-specific_connectomes_122015.zip
find . -...
20
votes
1answer
624 views
Are SELinux rules enforced before or after standard linux permissions?
When SELinux is installed on a system are its rules enforced before or after the standard linux permissions? For example if a non-root linux user tries to write to a file with linux permission -rw-----...
2
votes
2answers
46 views
Overwrite a portion of a file w/o modification to the unmodified content [duplicate]
I'd basically like to create an allocated file lets say 1GB with content. Then hopefully using some command line utility I'd like to overwrite-in-place a portion of the file, lets say the beginning 4 ...
1
vote
1answer
37 views
How to make hacked files in Subversion repository editable again?
I'm investigating some files in a website which were hacked and the site is under version control in a Subversion repository, but it doesn't show the files as being modified. How do I stop SVN from ...
1
vote
1answer
27 views
File system symbol on “+” (drwxr-x---+ 2 root root 4096 Jan 20 21:48 myusername)
What is the meaning of "+" in ls's output? There is a symbol behind drwxr-x---. The "+" is a new sign to me. I heard ACL (Access Control list). Does anyone know more about this? I saw it on my mount ...
16
votes
6answers
1k views
How to remove the last line of all files from a directory?
I have many text files in a directory, and I want to remove the last line of every file in the directory.
How can I do it?
3
votes
2answers
42 views
Where are i-node tables stored?
I do not really understand where the tables which contain i-nodes are located. My teacher said that each physical disk has a table of i-nodes, after which there is the files' data. But, on the ...
2
votes
1answer
49 views
Use head command or similar to determine when bytes change in a file
If we use the tail command we can listen for events representing changes to the files length (in bytes).
I am looking for a way to listen for events when the content of the file changes but the ...
0
votes
2answers
52 views
How do I untar a set of files in a directory?
There are about 10,000 files in the directory some of which are .fits and some of which are .tar. Now, I need to untar only the .tar files. Although running an if condition seems reasonable, the untar ...
1
vote
2answers
51 views
Is there a way to know percentage of images and code in a given directory? [closed]
Let's say you download some .zip/tar.gz or source-code of a project from somewhere. The result you will get are a random bunch of files, some having code and some having images. Is there a way to get ...
30
votes
1answer
2k views
Why are executables in e.g. /usr/sbin writable by root?
Could you please explain why a binary compiled file (in, for example, /usr/sbin) has write permission for root user?
For me, this is compiled. Meaning that direct write has no use and may expose file ...
3
votes
1answer
47 views
Rename files to the inode
I'm trying to rename files in a directory based on the inode number. That seems to be the unique number that will keep the files (pictures) in the order in which they were taken. I want to do this as ...
0
votes
1answer
28 views
Test for file existence only work for exactly 1 file, how to have it work for 2 files? [duplicate]
If I have any a single xyz.PDF file this works:
[ -e *.PDF* ] && echo 'yes'
However if I have two files, e.g.
xyz.PDF
abc.PDF
I get
$ [ -e *.PDF* ] && echo 'yes'
-bash: [: ...
8
votes
3answers
660 views
Change only the extension of a file [duplicate]
I am working on a simple shell script to change a file one.PDF to one.pdf. I have this file stored in a folder called Task1.
My script is in the same directory as Task1. Called Shell1.sh When I run ...
1
vote
1answer
64 views
Check if file exists in S3 Bucket
This directory /data/files/ has thousands files like:
1test
2test
3test
[...]
60000test
60001test
I'm also sending them to a S3 Bucket (AWS), using AWS CLI. However, sometimes the S3 bucket can be ...
1
vote
2answers
32 views
In spite of proper permission not being able to cat the file
I want to cat /home/ubuntu/.gnupg/gpg.conf which has 0600 permission.
λ ubuntu [~] → sudo stat /home/ubuntu/.gnupg/gpg.conf
File: ‘/home/ubuntu/.gnupg/gpg.conf’
Size: 9398 Blocks: 24 ...
1
vote
0answers
66 views
Find to list files for not matching given string [duplicate]
I am searching all *.out files from a specific directory and trying to list all the file names where the given string is not present in those files or not matching by executing the below-listed ...
1
vote
1answer
24 views
Program to edit Default Applications (for MIME types)
Is there some nice programm (not necessary with GUI but would be nice) to edit my preferred applications for MIME types?
I want to change e. g. default browser and default image viewer without ...
1
vote
0answers
10 views
Inconsistent single- and double-clicks in GNOME/GTK file manager
I mostly use KDE programs and just use the Awesome WM as window manager. There the KDE/Qt file dialog works with single clicks everywhere. A single click will enter into directory and also select a ...
0
votes
1answer
40 views
How does “cat” handle large files when used as part of a pipe?
Suppose I cat a file having size of say 10 GB, and I pipe that to head, would cat work if my system only has 2 GB of RAM and 1 GB of swap space? I want to know the internal details.
3
votes
2answers
127 views
How to set (find) atime in seconds?
How do I set -atime in milliseconds, seconds, or minutes? The default is days:
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was ...
5
votes
1answer
53 views
Why can touch change only all times, or nothing when not owner
We have a file foobar not owned by me, but it is in my group:
$ ll
total 4,0K
-rw-rw-r-- 1 root hbogert 4 jan 19 12:27 foobar
I can touch it and it will update all times:
$ stat foobar
File: '...
0
votes
3answers
75 views
How to Delete All the Files in the Current Directory Except the Last Two [duplicate]
Let's say there are 10 files in this current directory /home/usr.
They are numbered 1-10. If I wanted to delete all the files except 9 and 10, how would I go about it?
I can select the bottom two ...
0
votes
1answer
25 views
How can I move a file within a directory to the current working directory without renaming?
How can I move a file within a directory to the current working directory without renaming?
I can mv a file from current working directory to the parent directory without renaming using the shorthand....
5
votes
1answer
54 views
Rename files to change punctuation and numbering
I was hoping someone with better regex skills could help me with some files I need to rename. I need a command to recursively rename a large number of jpg files in Ubuntu.
However there are some ...
1
vote
0answers
17 views
File explorer fails to start when I run it and disappeared from Favorites [closed]
Few days ago I installed the Linux update. Of course it wasn't working, because of my chipset compatibility. I'm turning on the old version of Linux Threw GRUB, but there's a problem with my File ...
2
votes
0answers
29 views
“Union” based file manager
I would like to be able to perform actions on files in different locations within a common window/container. Let's say I have the following directory structure:
└── DCIM
├── browser-photos
│ ...
0
votes
2answers
71 views
How to download multiple files at once from a web site
How can I download multiple files at once from web page. For example I want to download all the plugins at once from this page.
What I did until now is that every time I needed the file url I would ...
1
vote
2answers
46 views
Viewing relevant information about file accesses from the audit log
Assume, you have a Linux machine and there are three users -
user1, user2 and user3, who can log in to the machine.
You created a rule
$ auditctl -w /etc/file.txt -p rwxa
If you would like to see ...
0
votes
3answers
22 views
How to use grep for finding file location in linux machines? [duplicate]
How can search for a file in ubuntu os with grep command ?
Let's say, I want to find CMakeList.txt, how to write grep command to find the existence of this file ?
0
votes
1answer
76 views
Bash: Sort Array Elements by File Date [duplicate]
I have a Bash script that has an array called myarray.
This array contains complete file location paths for 4 files.
What I am trying to do is sort the array elements by the file creation date.
So ...
3
votes
5answers
43 views
Only select directories and order in specific way with echo
I am not experienced in the Unix environment and have to adjust a script. I guess this is basic knowledge but I could not find a simple solution by googling it.
The script gets all webappsrv in a ...
0
votes
2answers
65 views
how to replace a character in a set of file names? [duplicate]
I have a set of image like that :
01-12_13:20:12_1366x768.png 01-12_13:20:46_1366x768.png 01-12_13:21:01_1366x768.png 01-12_13:21:06_1366x768.png
01-12_13:20:40_1366x768.png 01-12_13:20:...
3
votes
2answers
61 views
How to view the size of the binary files using linux command?
I have the binary file csimu under the following path /data/local/tools/bin.
I checked the size of the binary file using du -sh csimu, but it shows size as 0. But I have binary contents inside the ...