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
32 views

How to use `tree` to print the directory structure to a text file?

To print the directory structure to the console I use tree: $ tree -d . ├── figures │   ├── issue_33 │   │   ├── augmented_patches ... But for some reason I cannot do this to a file, as the ...
0
votes
1answer
40 views

C++ file reading style in bash

Assume that I have a file like this: [inp] // This is the file name 2 1 2 3 5 7 9 This would be read in C++ using this code: main() { freopen("inp","r",stdin); // Redirect stdin to file, while ...
7
votes
2answers
1k views

Why are there no file insertion syscalls

To my understanding, for manipulating files there is only the sys_write syscall in Linux, which overwrites the file content (or extends it, if at the end). Why are there no syscalls for inserting or ...
1
vote
1answer
24 views

A simple way to update the access time of multiple files

I have a folder with several sub-folders and files. I work on a server where any files that are older than 60 days are automatically deleted. What are some simple commands to update the access time (...
1
vote
1answer
27 views

macOS version file

This is kind of a weird one, does anyone know what contains the information of the version of macOS? is it written to some file? If so where does the file reside and can it be edited to a different ...
2
votes
0answers
21 views

Annotating any files

I have had this problem for a very long time, had several discussions with friends, and tried searching relating info online. All efforts were in vain so I decide to give a shot here. I have lots of ...
1
vote
0answers
16 views

to set the default permissions on files under a specific folder

Scenario: We're receiving the below files from upstream which is a mainframe system. -rw-rw---- 1 s36748 xyz 293 Jun 6 19:20 CSJ_H_20190606.csv -rw-rw---- 1 s36748 xyz 3284 Jun 6 19:20 ...
1
vote
1answer
26 views

My /usr directory is 100% full. Unable to download packages

What kinds of files are okay to delete in /usr directory without blowing up the server?? Is it possible to increase the size of /usr directory without blowing up server?
0
votes
2answers
16 views

split output into multiple files after reaching a certain size with correct file-extension

I use make | tee >(split -d -b 10000000 - debug.log.0) to split the output into several debug files after reaching 10MB. this results in files called debug.log.000, debug.log.001, debug.log....
0
votes
1answer
52 views

How to prevent someone with remote access from changing my file permissions?

If someone gets unwanted remote access to my computer/OS, what's to prevent them from opening a terminal and changing the permissions on my files? I have a FW that is very good, but, let's assume ...
0
votes
0answers
28 views

Conditional deleting of duplicate files

I have seen similar questions, but it seems my desired result is not covered in the answers. I want to delete duplicates only if files share the same name. Something like: rdfind -deleteduplicates ...
0
votes
2answers
28 views

Finding a file by alphabetical order

Using bash, I need to be able to find a file in a specific position when listed alphabetically. For example, if I had the files a, b, c, d, e in a directory, and I wanted to find the third file, I ...
1
vote
2answers
44 views

How can I find the latest log for multiple jobs in AIX and delete the latest one

I am new to unix. I am trying to find the latest log of multiple jobs and delete the latest one. Can I write a shell script for it? I have tried with basic commands, but there it is selecting a ...
2
votes
1answer
41 views

Compare two folders for missing files

I have two different folders each with the same file names in it but one has missing files. How am I able to compare the two folders Folder1 and Folder2 and list the files missing in Folder2 which ...
0
votes
1answer
19 views

Sony MSV files on Linux

I have just bought an old Voice recorder second hand ( Sony ICD-SX68). When I connect it to ubuntu it shows up as a usbdrive with my recorded files. The problem is the file format of the recording. ...
1
vote
1answer
39 views

Bash Script to create a file for each unique permission in a listing/find command and printing each directory/file path instance of that permission

I'm trying to create a bash script that will be able to perform a find command to get the permissions and full path of every file/directory in a directory tree and create a file for each unique ...
-2
votes
1answer
37 views

Alternative file ”open“/“save as” user interface?

One of the greatest advantages of Windows over Linux is the IBM Common User Access user interface with “Open File”/“Save File as”. It has separate bars for breadcrumbs folder navigation, search and ...
0
votes
0answers
28 views

append to a string in loop not working

I have a ksh script, where I am trying to read from file in a loop and append certain values to each line in the file. It is not working. Below is the code: Code snippet: input="$...
1
vote
1answer
37 views

How to express `find`'s -writable and -readable tests, when they are not available?

Sometimes on old Linux systems, I experience that find doesn't support -writable and -readable tests, which test whether the file or directory is writable/readable resp. for the current user. Say, I ...
0
votes
2answers
53 views

How do I not delete files in only the directory I am in?

I want to delete files older than 30 days in a directory, but not in directories below the one I am in.
0
votes
2answers
44 views

Compare two directories for a certain extension and then move the missing ones to a new directory [closed]

Editing and changing the verbiage to make it more clear - I have .dm4 files in both dirA and dirB. My reference folder is dirA and I want to list all the .dm4 files which are missing in dirA which are ...
1
vote
1answer
38 views

Why is ls show file size different when changing block-size?

I wanted to check my filesystem backup size ls -lia backup.tgz 17 -rw-r--r-- 1 root root 84972633333 мај 28 10:05 backup.tgz With block-size M ls -l --block-size=M backup.tgz -rw-r--r-- 1 root ...
1
vote
0answers
55 views

How do I merge identically named files?

My question is similar to this one but the answers don't address how I would like to solve it in my case: Background: I have two computers generating experimental results that are filed in ...
3
votes
2answers
105 views

Rename photos to match video titles

I have a mostly automated media server and currently have everything going into one folder and being sorted out by file extension into the correct locations. At the moment the photos are coming in ...
0
votes
0answers
14 views

properly copying a thunderbird local directory

I back up certain directories on a nightly basis to a local NAS using rsync. Because of a recent problem I had on my machine, I decided to also make a complete copy of the local directory that ...
3
votes
1answer
42 views

Test if any files that do not match a specific pattern exist in a directory

I am having much difficulty with this. I am trying to test if there exists files in a directory that DO NOT match a given pattern, returning true or false. In this case, files in $dir that don't ...
1
vote
2answers
40 views

Save output of multiple commands to the same file [duplicate]

For example whoami and date. I can do this that way whoami>/home/user/folder/file date>>/home/user/folder/file But i'm sure it can be done in one line without typing path two times. I have ...
0
votes
1answer
20 views

Is it possible to recover overwritten files from another operating System on the current operating system?

On my PC I had 2 operating sytems (ubuntu and windows) and for about 5 days I wanted to reinstall my Windows OS because of some bugs but instead of installing it on the partition where my old version ...
2
votes
1answer
61 views

Why can't I access a symlinked directory

I want to (soft)link my .thunderbird dir onto the actual directory which is on a SD card. Thus, (xenial)florian@localhost:~$ ls -la /var/host/media/removable/SD\ Card/.thunderbird/ total 24 drwx-----...
0
votes
2answers
55 views

Unix command to get 0 count , when no files present for the day along with count

How to do I get the list days were no files been received. Have used the below command to get the file count along with the date: find . -maxdepth 1 -type f -printf '%TY-%Tm-%Td\n' | awk '{array[$0]+=...
-1
votes
2answers
61 views

Is it possible to recover a deleted file from crontab -r? [duplicate]

I made a very serious mistake. I was editing the crontab file of my remote server, I was as the root user and it turns out that I wrote crontab -r instead of crontab -e and without previous notice it ...
0
votes
1answer
43 views

cant delete files

im tidying up my back up drive root@raspberrypi:/media/pi/Seagate Expansion Drive/Jane-PC# ls -la | grep Goo drwx-w--w- 1 pi pi 4096 Nov 17 2016 Google Calendar - Month of Nov 2016_files -rw-----...
0
votes
2answers
44 views

Owner of the file not being displayed properly in LINUX Terminal

I want the terminal to display the user name that created a particular file, so when I traverse all the way to that file and type in the command ls -l filename.docx or even ls -la /path/to/file, it ...
1
vote
2answers
41 views

View and delete part of data in binary file

How to delete part of binary data from binary file? (hex dump). I tried GHex 3.18.0 binary file editor, but it's not suitable for this, just lack even simple features. For example, I need select the ...
0
votes
1answer
61 views

Converting multiple commands into a for loop

It gets annoying to retype the commands in the terminal so many times. Basically, instead of just running these commands for ogg_2x2 or ogg_1x1 like in the examples in the image, I need to run these ...
2
votes
0answers
37 views

Automatic symlink to latest folder

Is there a way in Linux to automatically maintain a symlink to the latest version of a file/folder in a certain location? My use case: I generate datasets with unique job names, then write them to a ...
0
votes
1answer
49 views

How to give permissions to all files of a server in a user without making him the owner

Recently I had a project which was about ssh connection with an Amazon EC2 server. In this project I was asked to create a user than can have read permissions -only- to the whole server (all files in ...
1
vote
2answers
48 views

standard/simple way to mount remote directory

There is a shared_data directory in each of my client machines and I want to mount them all in my server. What is the most simple/standard way to do it? NFS seems more suitable for sharing directories ...
0
votes
1answer
54 views

Restore function in unix

I have a script to recover files back to their original location. I am missing the options for the script to as "Do you want to recover this file?" Yes or No. How will I implement it into this code ...
1
vote
2answers
38 views

Overwrite or don't copy?

I'm trying to copy a file only if it already exists, not if it doesn't, basically overwrite only on Linux. Does anyone know a solution? I basically need to "look" for a folder then if a file exists, ...
0
votes
1answer
58 views

Moving files to a bin [closed]

I am having issues with my code below: #!/bin/bash #Removing Files into the Recycle Bin(Deleted Directory) filemove=$1 #Saving the first argument as "filemove" mkdir -p ~/deleted #Create the deleted ...
1
vote
1answer
17 views

NFS client resetting another NFS client file pointer

I have a device that writes logs to a logfile on an nfs mountpoint. It writes to the same logfile "forever" resulting in a file that gets insanely large. I have a script (running on another nfs ...
0
votes
2answers
39 views

How to find more than one space and replace it with one space?

I want to find repeated spaces (more than one) and replace them with one space. I tried: sed -e 's/ []+/ /g' myfile.txt > myfile2.txt This resulted in an empty file. Why? and how to achieve my ...
0
votes
1answer
17 views

How to express beginning and end of line in sed

I want to use sed to replace every '} that comes at the end of the line to "}. I wrote: sed -i -e "s/'}$/\"}$/g" But this replaces it to: "}$. What is wrong? How can I use regex in my sed to express ...
1
vote
0answers
60 views

Curl download speed restricted when down/uploading from stdin/stdout

I'm running 2 curl commands where one downloads all the data into stdout/in until the stack is filled and another uploading whatever is in it out but it seems like the speed is restricted. For the ...
12
votes
4answers
1k views

How to rename multiple files in a directory at the same time

I have directory say /var/tmp/abc which has 4 files: 12345-ram-3e3r5-io9490-89adu9.csv 45434-dam-qwe35-to9490-43adu9.csv 11234-cam-yy3r5-ro9490-85adu9.csv 14423-sam-hh3r5-uo9490-869du9.csv I want to ...
0
votes
0answers
9 views

UsbFlashDrive.getLabel meaning

reading through the system logs I can see those two messages USBFlashDrive.isMediaPresent - the media is present in the device USBFlashDrive.getLabel - Getting the label for the USB flash memory ...
4
votes
2answers
321 views

Size of a folder with du

I have copied a folder using rsync including symlinks, hard links, permissions, deleting files on destination et cetera. They should be pretty identical. One folder is on a USB drive and the other on ...
0
votes
1answer
29 views

How to search for a newline that is not preceeded by } and remove it

I want to use sed to search for line breaks that are not preceded by }. The regex for identifying theses cases is: [^}]$ . What I want to say: If the line ended without } then remove the new line. ...
1
vote
1answer
39 views

How to get the list of files in a directory

I try to create an array/list which stores file names inside a folder. The below command creates for unknown reasons a :. How is possible to remove :? > a=$(ls split*) > echo $a split_sam....