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

learn more… | top users | synonyms (1)

3
votes
6answers
59 views

Sort files by highest number in filename

I've got a bunch of files all named like this: name_file-1.txt name_file-2.txt name_file-3.txt some_other_file-1.txt some_other_file-2.txt There are thousands of different filenames, some with just ...
0
votes
2answers
21 views

Bulk rename, change suffix? [duplicate]

How can I bulk replace the suffix for many files? I have a lot of files like NameSomthing-min.png NameSomthing1-min.png NameSomthing2-min.png I would like to change all them to NameSomthing.png ...
1
vote
2answers
24 views

Help creating script to move files based on date or filename

I have an FTP process that is constantly putting files into a directory. The date created is part of the filename in a format like this: YYYY-MM-DD-HH-MM-SS-xxxxxxxxxx.wav I would like to move the ...
3
votes
3answers
28k views

Copy only regular files from one directory to another

I'd like to copy a content of directory 1 to directory 2. However, I'd like to only copy files (and not directories) from my directory 1. How can I do that ? cp dir1/* dir2/* then I still have the ...
1
vote
1answer
47 views
+50

Lost Folders and Files in the directory /home/ubuntu/ in Ubuntu

I have uploaded a .tar file in /home/ubuntu/ and un-zipped the file in the folder name 'analytics'. After reboot, I couldn't found the directory and the tar files. I have checked it through SSH ...
26
votes
7answers
36k views

How do I grep recursively through .gz files?

I am using a script to regularly download my gmail messages that compresses the raw .eml into .gz files. The script creates a folder for each day, and then compresses every message into its own file. ...
0
votes
3answers
40 views

get IP address who modified a file

I am looking a way to to get the history of a file, like the modification date, who modified this file (ip address or username), the changed lines Is there a way to get the IP address or username of ...
36
votes
5answers
65k views

Script to monitor folder for new files?

How do I detect new files in a folder with a bash script? I would like to process the files as soon as they are created in the folder. Is this possible to do so or do I have to schedule a script with ...
6
votes
4answers
491 views

How to gather byte occurance statistics in binary file?

I'd like to know the equivalent of cat inputfile | sed 's/\(.\)/\1\n/g' | sort | uniq -c presented in ...
0
votes
1answer
10 views

Extract field values values from log file

How to extract the specific field values from log file using unix command. For example my log file contains, ...
3
votes
2answers
29 views

How do I transfer (to a usb drive) or read a .odt file in the command-line?

Currently my computer is not allowing me to start it up properly (guessing my hard drive is malfunctional), but I've figured out that Ctrl+Alt+(F1,F2,F3,F4,F5,F6,OR F7) allows me to access ...
3
votes
2answers
42 views

When can I omit the dot character that indicate the current directory

Should I use dot to indicate the current directory for accessing directories or should I use it for files only? For example, if the current directory is foo and it contains bar directory and baz.txt ...
0
votes
0answers
18 views

Script acting as textfile, possible? [duplicate]

A program I'm running has a -logFile option. The file I set as a logfile is filling up quite rapidly, and I only need about half of what's actually in it. Is it at all possible to: have a script ...
1
vote
1answer
38 views

Get the real, apparent size of a folder

I am using the du command in order to get the size of the folder. As I am interested in the actual size I ended up with the following command: du –sh --apparent-size <someFolder>/ In this ...
-4
votes
3answers
49 views

Write file names in to a file

In a directory I have X.txt,Y.txt,Z.txt files. I want to move these filenames into a single file like below: Out_file.txt X.txt Y.txt Z.txt Any unix command to achieve this?
0
votes
1answer
46 views

limit of open files: Debian Jessies´ MySQL vs Community Oracle MySQL

I have just upgraded from MySQL Jessie 5.5 to MySQL Oracle Community Edition v5.6. I have a particular MySQL server, that has around 230 DBs, and > 32k files/tables. Whilst for two or three years, I ...
0
votes
2answers
26 views

How to change the first column of data in a file?

I have .data file containing a table of numbers with the column format: m x y z vx vy vz separated by tabs, with a depth of 2000. The file name is initc.data. I want to change ...
1
vote
3answers
113 views

Finding and removing words beginning / ending with numbers

I have a large file (>10000 lines) that contains one word per line, with a newline character after each word. The words contain no spaces. I'd like to list (or even better, output to a new file) any ...
19
votes
6answers
33k views

Test if there are files matching a pattern in bash

I am trying to write an if statement in bash to test whether there are any files matching a certain pattern. If there is a text file in a directory it should run a given script. My code currently if ...
1
vote
1answer
22 views

Wipe files from an external hard drive but not empty space

I'm using the following command to wipe an external drive. sudo shred -v -z -n 1 /dev/sdb Is it possible to wipe an external drive of the files and not empty space? So it would overwrite where ...
9
votes
2answers
2k views

Tool in unix to subtract text files?

I have a large file composed of text fields separated by semicolons in the form of a large table. It has been sorted. I have a smaller file composed of the same text fields. At some point, someone ...
0
votes
1answer
39 views

linux compare text file [duplicate]

I have file1.txt and file2.txt, both contain URLs, I want to create a new file with the unique URLS present in file2.txt and not in file1.txt. Example urls file: aspencabinets.com.au iiatca.org ...
1
vote
2answers
39 views

How to remove prefixes and suffixes from filenames in a given directory?

I have many files with the same prefix and the same suffix. I want to remove both from filenames. Both contain spaces. So foo bar XXX doo par.jpg, foo bar YY YY doo par.jpg would become XXX.jpg and ...
2
votes
1answer
40 views

Information leaks out of encrypted file system

If I only encrypt the home directory, what are some common ways for information to leak out to the unencrypted part of the file system? Aside from the obvious problems like swap space files in /tmp ...
1
vote
3answers
36 views

Run a command over directories with name recursively

I have the following directory structure in AIX. codeRepo/REPO1/AREA1/objects codeRepo/REPO1/AREA2/SUBAREA1/objects codeRepo/REPO1/AREA2/SUBAREA2/objects From codeRepo I want to run chown myUser * ...
0
votes
0answers
20 views

meaning of !(something) in shell [duplicate]

While searching for a way to move all files in a dir to one of its sub-folders, i came across mv !(something) something which should do the job - but only in bash. However i could not find why. in ...
3
votes
1answer
22 views

Locate and manage files on extern hard drive through FileZilla over SSH

I have installed Debian Server on one of my servers and plugged in a extern hard drive to it through USB (sdb1, 2, and 5 on the image below) where I have all my files on right now. Before I used this ...
28
votes
4answers
21k views

Reading lines from a file with bash: for vs. while

I'm trying to read a text file and do something with each line, using a bash script. So, I have a list that looks like this: server1 server2 server3 server4 I thought I could loop over this using ...
0
votes
0answers
19 views

Most efficient way to replace a line in a text document? [migrated]

I am learning to code in Unix with C. So far I have written the code to find the index of the first byte of the line that I want to replace. The problem is that sometimes, the number of bytes ...
3
votes
2answers
288 views

Outputting common lines from 2 files and uncommon lines from both the files in one output file

I have 2 text files. Lets name them file1.txt and file2.txt file1.txt is as follows chr10 181144 225933 chr10 181243 225933 chr10 181500 225933 chr10 226069 255828 chr10 255989 267134 ...
-1
votes
0answers
16 views

CHMOD in FTP block - RESOLVED [closed]

trying to change permissions on a file i'm FTPing to multiple servers. Using this in a shell script: ftp -n -v $TIP <<EOF | tee -a $FTPLOG user $TUSR $TPAS binary cd $TDIR/bin rename ...
5
votes
1answer
19 views

What are SELinux “.lst” files under /usr/share/selinux/targeted on CentOS 7?

I can see several ".lst" file under /usr/share/selinux/targeted on CentOS 7: base.lst modules-base.lst modules-contrib.lst nonbasemodules.lst ".lst" files contain a list of SELinux policy ...
1
vote
2answers
61 views

Save file after using sed command

I am using following command to replace yyyymmdd to YYYYMMDDHH24MISS in my file: sed -e 's/\('yyyymmdd'\)/\('YYYYMMDDHH24MISS'\)/g' filename After I run the command in PuTTY, it displays the file ...
0
votes
1answer
21 views

File -> ../../archive/folder/file restore

Hi i'm new to Linux and I need to use it temporary to set up LetsEncrypt. Once complete, I needed to move the /etc/letsencrypt/live/fullchain.pem file into the root dir but i moved the file ...
10
votes
5answers
804 views

How to print file content only if the first line matches a certain pattern?

I am writing a script, I want to check if the first line of the file matches a certain pattern and if it does then print out the file. How can I achieve this? How do I check for pattern? Is there a ...
5
votes
2answers
68 views

Search directories for multi line string

Looking for a way to recursively search a repository for all files containing a multi line string and return the file names that contain it. The paragraph is just a header approx 30 lines. So I know ...
3
votes
2answers
2k views

Why can't I delete this file as root?

I have directory exam with 2 files in it. I need to delete files but permission is denied. Even rm -rf command can't delete these files. I logged in as a root user.
2
votes
2answers
37 views

Renaming a file the moment it appears in a folder

Here's the context : on a samba server, I have some folders (that we'll call A,B,C,D ) which are supposed to receive files from a network scanner. The scanner renders a PDF file named like this : ...
4
votes
1answer
43 views

Prevent processing file until SCP transfer is finished

Large files are transferred to a server for processing. The server monitors a specific directory using incrond and when a new file is received the processing script is executed for that file. Because ...
3
votes
1answer
970 views

Compare file size of multiple files in an array [closed]

Scenario: Ftp site has 100s of files. Once a day, all the .gz files are copied to an AWS site then renamed. Only the date is kept in the file name. Some of the files corrupted during copy. A txt ...
10
votes
8answers
308 views

sed in-place line deletion on full filesystem?

Due to an application bug as yet undiagnosed, I have several hundred servers with a full disk. There is one file that has been filled up with duplicate lines—not a log file, but a user environment ...
0
votes
1answer
34 views

How can I upload my .cpp file online while logged into schools Linux server through SSH?

I am currently in a basic programming class, and I finished my first project and it is a .cpp file. I am logged into the Linux server but I do not know how to upload a .cpp file online when I can only ...
1
vote
1answer
26 views

Symlink to same directory

I've set up a ftp server for using ftp push on a tv recording page. I've created an extra user for this, who has only access to one directory, which the user is chroot-ed in. But the page does not ...
0
votes
1answer
20 views

How to safely delete a regular directory that contains several btrfs snapshots inside it?

I have a regular directory than contains directly underneath it several btrfs snapshots. Is it safe to do an rm -rf on the parent directory, or do I need to first do a btrfs subvolume delete SUBVOL on ...
6
votes
6answers
783 views

Exclude directories in locate search

A search with locate finds paths in the filesystem. Often, you know a priori you are interested in either files only, or directories only. A 'locate' search often returns many results. It would be ...
7
votes
5answers
2k views

Delete all files in a directory whose name do not match a line in a file list

I have a directory with 1000+ files. In a text file, I have about 50 filenames, one per line. I'd like to delete all the files in the directory whose filenames don't correspond with an entry on the ...
4
votes
1answer
272 views

Find the files between two folder dates in linux?

I need to find the folder names along with the file names which has my string in their contents. I am in this directory "/data/queue/data" and I have lot of folders in the same directory and inside ...
2
votes
2answers
910 views

Any way in Bash to write to a file every X seconds without closing it?

The hardware watchdog on my system needs a 0 written to /dev/watchdog at less than 60 seconds interval or it will fire. The file handle must be kept open however or the watchdog is then disabled. ...
3
votes
2answers
987 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 ...
5
votes
0answers
57 views

Why does OS X `install` errors on redirected input when the same version of `install` on linux works fine?

I would like to use install command in order to create a new executable file with pre-populated content (e.g. with single pwd command in it). So I've extended this example which creates a new empty ...