Questions tagged [filenames]

File name is a name used to identify a file uniquely on given file system.

Filter by
Sorted by
Tagged with
0
votes
2answers
36 views

Search Unix file name by positions of the characters in file name

I have 2 files. File 1 = ABC2019120601C File 2 = ABC2019120611C If I type ls -l ABC*C it will output all 2 files. Is there a way to find files by exact position of the character? For example 1st ...
0
votes
1answer
20 views

Copying files with spaces in the name using a shell script [duplicate]

I am using this script to mv all the files from a shared directory to another directory: cd /share while : do for allfiles in $(find /share/ -maxdepth 1 -type f -iname "*" -mmin +1); do sudo mv "$...
0
votes
1answer
25 views

How can i delete all files using pattern matching and recursively through directories

I have files in this format: 12.999.jpg 34.999.jpg 45.999.jpg 12.555.jpg So, for example I wish to delete all files that have '999' as part of the file name. But, these files can be in seperate ...
4
votes
2answers
76 views

How to safely move and rename files based on REGEX into properly named directories

In a large drive, I have multiple hundreds of files each named differently but with a few regular expressions. Each appended with random numbers and sometimes characters. For example, there are 30 ...
0
votes
1answer
34 views

sort file of unix pathnames from two drives

I have a file containing pathnames from two directories. I want to sort them by filename disregarding parent directories. Text is as so: /mnt/samsung/a/b/c /mnt/samsung/d/e/f ... /mnt/wd/a/b/c /mnt/...
2
votes
3answers
51 views

How to sort subdir glob by filename, not full relative path

Given a tree of files like this: subdirFoo/2019-06-01-blah.ext subdirFoo/2019-06-07-blah.ext subdirFoo/2019-05-02-blah.ext subdirBar/2019-06-03-blah.ext subdirBar/2019-05-05-blah.ext subdirBar/2019-...
0
votes
2answers
24 views

Remove characters between a special character and a word

I have doing tons of research and can't seem to figure it out. I am using sed and trying to process a file of paths /path/to/somewhere/for-something.rar I need to remove everything past the last / ...
2
votes
1answer
52 views

Why is my directory getting quotes around it when created? [duplicate]

I create a directory called bob@example.com/ I wanted to use this email address as the directory name - I know - not a good idea for many reasons - but lets assume this is a very temporary ...
11
votes
4answers
646 views

Grep over multiple files redirecting to a different filename each time

I have a directory full of .tsv files and I want to run a grep command on each of them to pull out a certain group of text lines and then save it to an associated text file with a similar file name. ...
1
vote
2answers
33 views

rename files based on the directory name [duplicate]

for i in L*; do cd $i find . -type f -name 'botrytis_cinerea_T12345.*' -exec rename 's/botrytis_cinerea_T12345/"$i"/g' {} \; done I get the error find: missing argument to `-exec' rename: not enough ...
2
votes
1answer
45 views

rename 'y/A-Z/a-z/' * doesn't work on windows subsystem for linux (wsl)

When you do it it says file already exists. example output: rename 'y/A-Z/a-z/' * Totemic-1.12.2-0.11.6.jar not renamed: totemic-1.12.2-0.11.6.jar already exists TreeChoppin-1.12.2-1.0.0.jar not ...
1
vote
3answers
69 views

How can I give new file names while a program is working in a loop in cshell?

I have lots of .dat file and I want to convert them to .sac file (a type of seismogram file). I convert files with xy2sac program (I didn't write the code), but I have to give converted files a new ...
1
vote
1answer
20 views

how do I loop through selected file extensions in ZSH?

I am looking for a ZSH equivalent to this BASH construct: for file in *.{abc,def,ghi}; do #loop through all files with the extensions .abc, .def and .ghi I cannot find a similar construct for ZSH. ...
0
votes
0answers
43 views

Bash Script for Backing up/Gzip files with correct name

Having trouble forming a backup shell script for nested vm's There are multiple filenames (vm1, webserver, sshserver, etc.) with nothing in common other than .qcow2. I need to store just the ...
2
votes
4answers
87 views

Copy multiple files in multiple folders into one

How may I copy multiple files in multiple folders into one folder and change their names according to what directory they are copied from? Initial directory hierarchy: folder1/ file1.gz ...
-1
votes
3answers
164 views

find directory or file that ends in any 3 characters

i am trying to find directory or file that ends in any 3 characters with using ls -l /etc | grep ???$ and this doesnt work,, what should I type to find any directory of files that ends with 3 or ...
1
vote
1answer
37 views

Opening a file *with partially unknown filename* in executable directory

I have a directory in linux which I can eXecute. Thus, I should be allowed to cd into the directory and open the file(s). I know that the file I am interested in starts with f and has a number ...
1
vote
1answer
48 views

zsh: complete relative path as absolute?

I'm trying to write a completion function for a command that requires that its argument be an absolute path. (No, I don't know why.) I thought it would be nice to allow typing a relative path, but ...
0
votes
1answer
78 views

Can every file really own at least 2 names (and thus 2 hard links)?

This page on inodes has been exceptional help in grasping the surface-level concept of file systems. On the same page, the author has inserted this snippet demonstrating that each file or directory ...
0
votes
1answer
52 views

How to list directory names that do not contain a certain filename? [duplicate]

I have several hundreds of directories and in each of these directories there are files with date in their filenames, like this: $cd dir1 $ls 20190915.file.gz 20190916.file.gz 20190917.file.gz ... ...
3
votes
2answers
87 views

How to replace a column of numbers in a lot of filesnames

I would like to rename many files, named like this: cc cc nn - ccccccc ccc cccccccc - nnnnnn.mp3 where "c" means a character and "n" means a number cc cc nn - ccccccc ccc cccccccc - nnnnnn.mp3 ...
2
votes
1answer
60 views

How can I delete a file with the name “*”? [duplicate]

Someone who isn't me ran dd if=/dev/zero of=* iflag=fullblock,count_bytes count=200G, so now there's a 200gb file taking up space on my filesystem. Is there a way to delete it without running rm * ?
0
votes
0answers
22 views

How to remove multiple HTML files in batch

Ubuntu 16.04 LTS, Gnome version 3.18.2 My desktop filled with multiple html pages (GHex editor output). binary00000000.html binary00000001.html binary00000002.html ... binary00043310.html How to ...
1
vote
4answers
86 views

zipping files iteratively

I have a folder with 77K PDFs(~500 GB in size). I want to zip them into 77 zipped files, each containing 1000 PDFs, so that they are easier to upload and share with peers. I don't know how to write ...
0
votes
0answers
26 views

How to copy every N file when serialization is not consistent

I have a directory containing 101695 files ranging from img001.jpg to img101693.jpg and I want to move every 100th image to another directory. I have found some similar posts such as How to copy every ...
1
vote
3answers
277 views

Loop over files in directory - save their name to a file and then change name

As it is written in the title I want to write a program in bash that will do following: Loop over each file in a directory (there will be 100 files in each directory) Assign to it random number ...
-1
votes
1answer
85 views

Why is mktemp -u considered “unsafe”?

I read the --help text for mktemp recently (the man page wasn't available) and came upon this: -u, --dry-run do not create anything; merely print a name (unsafe) Why is this "unsafe"? Is ...
-1
votes
2answers
92 views

What command lists all files beginning with “a” and having 1 or 2 digits that follow?

What command lists all files beginning with "a" and having 1 or 2 digits that follow? (The output might display a0, a1, a2, a3, a00, a01, a99,... but not a333, not b12, not art53,...)
1
vote
1answer
75 views

UNIX/SED - Wildcard in file name

File name is: file_201909091143.csv How to add a wildcard to pull all files that start with 'file' ? #!/bin/bash #cleans blank rows sed -i '/^$/d' file?.csv #wildcard missing UPDATE directory's ls: ...
0
votes
3answers
42 views

How to extract the part of filename with specific pattern?

I'm looking to extract part of filename which I"m currently using position but it's not working as desired output. Sample data: ls -a *0728*dat | sort amnbmnbm_jnjmnm_sd_07282019_14_13_17.dat ...
2
votes
1answer
57 views

Is there a character that sorts before the newline character, for managing sort order in 'ls'?

I'm developing some file naming guidelines, and I'm trying to find a way to allow a draft document to list before a final revision. Example: Currently my naming convention looks like this: ...
2
votes
1answer
79 views

Bash copy command not working after file rename

I have this installer shell script in a bash script. I am doing a rename of the existing text file (backing it up). I remove old file Copy fresh file to the target dir mv /target/data.ini /target/...
0
votes
2answers
44 views

Unzipping Multiple Files Whithout Overwriting on Identially-Named Files

At an early stage of my script, it needs to unzip "x" amount of files provided by the user. Across the zipped file set, there are name-duplicates (but their contents differ from each other); i.e. both ...
-2
votes
1answer
55 views

Difference between GNU tar's --transform and --xform options

What is the main difference between GNU tar --transform to --xform? From reading the GNU tar manual, I assume they might be the same and the latter is a "sugar syntax".
0
votes
2answers
39 views

Extracting specific file names and putting them into the folder of their name

I am newby to Bash, Ubuntu 16.04. I have tons of files, which seems like: aaaa1111 aaaa1112 aaaa1113 aaaa1114 ... aaab1111 aaab1112 aaab1113 aaab1114 ... aaac1111 aaac1112 ... (and so on ...) ...
2
votes
1answer
83 views

How to change a file name containing “:” in timing info

I am learning Linux commands. When rename the file name with timing info, there are : marks automatically assigned. how can I change this : sign to _? Below is a file name example. It was updated ...
1
vote
2answers
128 views

How to change uppercase letters of my file name to lower case?

Which command change uppercase letters of file name in a directory to lower case? Thank you I have files F1 F2 FILE1 FILE2 I would like to rename them: f1 f2 file1 file2
8
votes
6answers
640 views

Find only those folders that contain a File with the same name as the Folder

I want to find all subfolders, that contains a markdown file with the same name (and extension .md). For example: I want to Find following subfolders: Apple/Banana/Orange #Apple/Banana/Orange/...
0
votes
0answers
22 views

File extensions for intermediate files needed for static / shared libraries

I have a library which until now was just a static library. The file naming scheme that I used was the following: foo.c -> foo.s -> foo.o bar.c -> bar.s -> bar.o }-> libfoobar.a Now ...
2
votes
3answers
371 views

how to change dot to underline in multiple file-names?

I have over 100 files named like x.assembled.forward.fastq.gz x(n).unassembled.reverse.fastq.gz the problem is that the pipelines that I am working with do not accept 'dots' in the file name and I ...
2
votes
3answers
148 views

How do I rename multiple files which have a slightly different extension?

I have multiple files which all have a similar naming pattern like: {filename}.jpeg{random number} I want to rename these files so that their extension is just .jpeg. How can I do this?
0
votes
3answers
151 views

Remove leading zeros from middle of filename in Bash

This is a simple problem that I'm having but I'm not quite good with sed so any quick help would be appreciated. I broke a number of different files up into 100 chunks using split. As a result, all ...
1
vote
2answers
53 views

Remove Newline from end of Filename

I'm trying to clean up some files on a Linux NAS. They were transferred over from old storage years ago now files and folders include the newline character "\n" at the beginning and end of the file\...
2
votes
3answers
51 views

Extract a part of a filename

I have the filename TRNPRD.STD.BSRE.BREX.J.20190520.V02.PRET on a Linux machine, from which I need to extract only TRNPRD.STD.BSRE. I tried the following command: echo TRNPRD.STD.BSRE.BREX.J....
2
votes
1answer
56 views

Change file modified date using date from file name

Change last modified date of multiple files as per date mentioned in the file's name Files are 04-01-1981 XXXXXYYYYZZZZ.xml 19-11-1982 XXXXXYYYYZZZZ.xml 25-12-1981 XXXXXYYYYZZZZ.xml The reason it ...
0
votes
3answers
44 views

Check if a specific file with a specific name is running?

I am wondering is it possible to check if a specific file with a specific name is running? I see a lot of various cases that show PID's rather than a filename but would rather take a filename route. ...
0
votes
2answers
84 views

is it possible to remove a `:~` directory

I can see a directory got created :~ on my server How to delete it as I can't even do cd :~ and I tried deleting it sudo rm -R :~ but I can see a lot of things are inside that folder? What to do to ...
0
votes
2answers
204 views

Find file and rename on one command in bash

How can I find a file in a RHEL 7 server and rename it? Can this be done in one command? For example, I could: find . -name filename then cd to the directory then mv filename.conf filename2.conf, ...
0
votes
2answers
71 views

Find not working as expected with space in directory

I have a script calling this find "/mnt/Data/Shared/$1" -type d -exec bash -c 'fixperm "'${1}'" "fd" "$0"' {} \; $1 is a directory, when the name contains no spaces it works, when there is a space ...
1
vote
2answers
118 views

In MC: What does the * symbol means at beginning of a filename

I am using Ubuntu 18LTS. I am making changes to file located in /usr/bin/ but after reboot it came back as before and also the last modification date, so from that rises my question: what does this "*...