Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [files]

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
1answer
8 views

Can't remove files in the printer spool

I can't remove files in the printer spool for some reason: $ sudo ls /var/spool/cups lists a bunch of files like 'c00083' etc. $ sudo rm /var/spool/cups/* rm: cannot remove '/var/spool/cups/*': No ...
1
vote
1answer
36 views

Compare two directories: if files don't exist or are the same, move; else, do nothing

I have four types of files: JUST_SOURCE exist only in the source directory JUST_TARGET exist only in the target directory SAME exist in in both source and target directories, and have the same ...
3
votes
1answer
64 views

Some special files in Unix

Background There are lots types of special files in Unix, for example symlinks, device files and proc files (under /proc). /proc files are just normal files or even text files. But for the rest, I ...
0
votes
1answer
24 views

How to extract the first column in a file with multi-character delimeter?

I have a file in which I use a string like <xxxxx> to separate the fields. This was a choice to avoid problems with the comma separated fields and other types of single characters due to the ...
0
votes
1answer
26 views

How to fix this command mass renaming files to match a text file [on hold]

for file in *; do read line; mv -v "${file}" "${line}"; done < /var/www/html/uploads/songs.txt It works as in changing all 700 files. But it doesn't seem to do it in the correct order. I feel ...
2
votes
2answers
43 views

Print Folders Missing .txt Filetype

I have 150 directories in a parent directory. Some of them have .txt files, others do not. I would like to print which folders do NOT have a .txt file. How can I achieve this?
1
vote
1answer
48 views

Recursively converting Windows files to Unix files

I have a PHP application with is located on Linux with multiple directories (and sub-directories) and many PHP, JS, HTML, CSS, etc files. Many of the files have Windows EOL control characters and I ...
1
vote
1answer
27 views

How do I mass remove certain characters from directory/file names

What's a command I could use to do this on fedora 29 I need to remove [,], and -. If possible just remove the characters. Otherwise I'm good with replacing them as '_' I have 2,400+ files and ...
0
votes
1answer
34 views

Is there a syntax for the path of a file in the current or a parent directory?

I am writing a template engine and I would like to allow users to refer to a file at the current directory, but if it doesn't exist, look at the parent directory, and so on up to the source/ directory,...
0
votes
0answers
18 views

Questions related to VFS [on hold]

1) If we are doing a read operation, then after we find the pointers to the actual physical address we check with the content in the cache and if it same then continue with the operation, else suspend ...
0
votes
3answers
59 views

Zipping the 10 most recent files

Basically my requirement is to find 10 latest logs and compress it into zip. I have tried command ls -Lt | head -10 | zip log.zip *.log, but output is not matched.
1
vote
0answers
9 views

Protecting access to NFS shares in Docker

I would like people to access NFS shares from within Docker. Problem is inside of Docker they can become root, and then they can have write access to anyone's files by becoming that user. Is there a ...
0
votes
0answers
29 views

Archive all files in current dir [duplicate]

I couldn't found solution on this. How I can tar and gz all files in current dir without sub folders with bash script? I tried with #! /bin/bash tar -czvf all.tar.gz * Echo "archived" ..but ...
0
votes
0answers
10 views

How do I change the file permission to be able to write over a file using Netbeans?

I am trying to edit a file and when I open it using Netbeans IDE, I am not able to edit is as it is only a read-only file. I am able to edit using the GEdit Text editor and by running the command ...
-1
votes
0answers
16 views

USB transfer problems 99%

So I am having a strange problem on my pc running linux mint cinnamon 3.67 running kernal version 4.10.0-38-generic. When I try to copy files to a USB it says its copying @110mbps even if its a usb2....
7
votes
2answers
1k views

cat shows nothing

My team is working on a CI environment. A ko file, named x.ko, is always generated from the CI environment at a regular time everyday and its type is ELF 64-bit LSB relocatable. Today, I found that ...
0
votes
2answers
55 views

How to insert a line in a file after certain bytes

Let's say I have a large file (several gigs) with n lines in it. I would like to add/insert a line after k bytes offset, from the beginning of the file, then what would be the fastest way to achieve ...
2
votes
4answers
209 views

How to copy the rest of lines of a file to another file [duplicate]

I have the string xyz which is a line in file1.txt, I want to copy all the lines after xyz in file1.txt to a new file file2.txt. How can I achieve this? I know about cat command. But how to specify ...
0
votes
1answer
22 views

searching/showing size of files

is there an easy way to look through a directory and say, for every file that starts with a-z, print the total size of those files? for example for i in {97..122}; du (something); done i.e output>>...
0
votes
1answer
28 views

Adding magic numbers/file header back to a zip

As part of a program I am in, I have been given a zip file that won't open. I have worked out that the file header is missing from the zip, but I am not sure how to put it back. Simply replacing the ...
0
votes
0answers
15 views

libmagic thinks docx is application/octet-stream

On my Ubuntu 18 workstation when I check the mime type for a Word docx file I get the following: $ file --mime src/tests/data_sources/test_data/word.docx src/tests/data_sources/test_data/word.docx: ...
0
votes
1answer
38 views

Shell Script: Decrypt the encrypted password and store it in variable

I have a file "credential.txt" which contains the password of mysql. I have another script which calls this text file and retrieves the password from it. For security purposes, I don't want to store ...
0
votes
0answers
24 views

writing a variable to a file in a loop [migrated]

I am writing a variable to a file in a for loop, and each time the variable has a new value. for id in seqdata.keys(): sequence=">%s\n%s\n" %(id,seqdata[id][seqindex]) outfile.write(...
2
votes
0answers
36 views

AIX : NOFOLLOW_LINKS is not supported on this platform

I have an AIX 7.2 machine. I am trying to run a Java program on it. It gives me this error: NOFOLLOW_LINKS is not supported on this platform. It is because I am using this call in the program: Files....
0
votes
0answers
46 views

How does 200 million function call of fgets translate into only 25,224 system calls?

A I/O efficiency test from APUE: Test file is said to be "98.5 MB with 3 million lines." Code used in "Figure 3.6": #include "apue.h" #define BUFFSIZE 4096 int main(void) { int n; ...
-1
votes
1answer
47 views

Do we need to open a file to get its attributes?

int stat(const char *filename, struct stat *buf); int fstat(int fd, struct stat *buf); Do we need to open a file to get its attributes? To access the attributes of a file, do we need to access the ...
1
vote
2answers
89 views

Does Linux represent an opened directory in the same way as an opened file?

Linux kernel represents an opened file as an entry in the file descriptor table, an entry in the v-node table, and an entry in the open file table. Does Linux kernel represent an opened directory ...
0
votes
1answer
33 views

Why am I able to still write to a file marked 400

root@user123:~# touch 1.pwd root@user123:~# chmod 400 1.pwd root@user123:~# echo "abc" > 1.pwd root@user123:~# vi 1.pwd root@user123:~# ls -lart total 3344 -rw-r--r-- 1 root root 148 Aug 17 ...
0
votes
1answer
66 views

cp or ls command. File exist, but I get no such file or directory message

I have an linux car player. I need to copy libmedia-navi.so file from device to sd-card. But I can not. ls command lists some files with only "file name" and some files with "file name -> another file ...
0
votes
2answers
18 views

Navigate file easily in Linux GUI Apps?

This is not about File Manager as I can copy/paste or type the full path in the address bar. This question is about other apps, e.g. FeatherPad text editor. If you have a file buried deep within your ...
0
votes
0answers
14 views

Error in git install from source on Ubuntu

I get the error message install: missing destination file operand after 'git' I tried to install git but whenever I tried I get git clone https://github.com/lwfinger/rtlwifi_new.git Command 'git' ...
3
votes
4answers
233 views

How to remove trailing forward slash

For each line in my file, if the line ends with / I want to remove it. How to do this? My attempt: sed -e "s/$\/$//" myfile.txt > myfile_noslash.txt Did not work.
-1
votes
1answer
24 views

Search for a string in lots files in a directory, if found, save the file name and line

I have several files, with different names. no specific format for them. But all are .txt. For example: example.txt flower.txt abc.com.txt They are in the same directory. I want to search for a ...
6
votes
6answers
340 views

Checking for the existence of multiple directories

I want to check for the existence of multiple directories, say, dir1, dir2 and dir3, in the working directory. I have the following if [ -d "$PWD/dir1" ] && [ -d "$PWD/dir2" ] && [ -...
3
votes
0answers
52 views

I can see but cannot delete a file [closed]

I am running Linux Mint.I tried to copy a file with the file manager. It looked like it hung. I can see the file in the directory with ls -l: -rwxr-xr-x 1 mike domain^users 20 Mar 1 08:57 'output (...
1
vote
0answers
20 views

Zip64 Extra Information Field

While trying to analyze zip files, one section Im a little confused by is the Zip64 Extra Information Field. It is expected to be generated when specific fields can't fit in the file header(Central ...
7
votes
1answer
529 views

Is there a Linux system call to create a “view” of a range of a file?

Does Linux provide a system call which can create a "view" of a limited byte range of a backing file? I'm envisioning something that for example would act on an open file descriptor and either modify ...
0
votes
3answers
36 views

Move or rename subfolders

I have a folder structure like this: /ms/files/a/ /fb/files/a/ /db/files/a/ It should be like this: /ms/files/b/ /fb/files/b/ /db/files/b/ I can find the folders I need to move or rename using ...
-1
votes
0answers
68 views

Why can't I remove some files on an external hard drive?

On my external HDD with a single NTFS filesystem, why can't I remove some files? How can I solve the problem? Detach and reattach the external HDD to my computer doesn't help, so it seems no process ...
0
votes
1answer
44 views

cat shows file contents, gedit and vim show blank file

I was planning on building a current logging device with an Arduino, and tried starting off with the basic SD-card write example from the Arduino IDE sketchbook. The Serial console showed no errors, ...
0
votes
0answers
7 views

Mime Type defined but is not used by newly created files

I saw that mime type is set for md extension in the following file: $ cat /etc/mime.types | grep markdown text/markdown md markdown But, on checking the Mime type ...
0
votes
0answers
21 views

SFTP the latest file

I need to sftp to a remote server, find the latest file on the server, download the file, and rename the file so it's not used again. I have no control over the file naming convention, so I need to ...
1
vote
1answer
30 views

remove files under specific folder

What is the diff between the following two approach ? find /calc -type f -delete find /calc -type f -exec rm -f {} + my target is to remove any jar file/s under calc folder any prefered of one of ...
0
votes
1answer
49 views

Tail a file while it's open for writing

I'm writing continuously to a file, and I want to tail it from another shell. But it seems that as long as the file is open for writing, tail -f filename can't show all the new lines until the file ...
1
vote
1answer
62 views

Allow user to remove file owned by root

I have a limited user and access to root. How can I give that user the possibility to remove files owned by root? I have the following line added in /etc/sudoers.d/john : john ALL=(ALL) NOPASSWD:/...
0
votes
1answer
20 views

What does “whether synchronized I/O can be used with the associated file” mean?

From Advanced Programming in the UNIX® Environment: For _PC_ASYNC_IO, _PC_PRIO_IO, and _PC_SYNC_IO, the referenced file must not be a directory. Name of option | Indicates ... ...
0
votes
1answer
122 views

Is there a tool in Linux to add an extended attribute to a file?

The getfattr tool is used to get the extended attributes of a file, but is there a tool to add an extended attribute to a file?
-1
votes
1answer
28 views

move files based on content

I want to move all files that contain a number greater than 25 (at least on one instance) but don't contain any number smaller than 25 after the string >randomnumber_xxx_ to a specific folder. ...
7
votes
2answers
365 views

Echo to file descriptor overwrites the file?

I am having trouble understanding what is happening when I try to write to a file descriptor? It appears to be overwriting the original contents? Is this expected behaviour? I have replicated this in ...
0
votes
0answers
37 views

How to run command recursively on files within directory and sub-directories within? [duplicate]

How can I run the command below recursively on all directories and sub-directories within? [someone@someones-pc ~]$ for i in *.mp4; do ffmpeg -i "$i" -i watermark.png -filter_complex "overlay=1623:25"...