Stack Exchange Network

Stack Exchange network consists of 174 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 [filenames]

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

0
votes
1answer
62 views

How to strip out white space of a filename

Opering System : RHEL 7 Bash Script: V_No=10.8.3 BUILD_VERSION=`echo ${V_No} | tr ' ' '_'` echo "File Name: Dev-${BUILD_VERSION}.jar" output: File Name: Dev-10.8.3 .jar expected output: File ...
1
vote
1answer
45 views

Linux grep for file starting with certain letter AND contain certain words

Trying to search a file directory for file names beginning with "h" and containing "enu"? So far this is what I've got, I just don't know how to handle both grep statements in one command line? find ...
1
vote
1answer
27 views

Remove files in linux with different folder files to delete in a folder as particular folder

I want to remove multiple (all) files with different suffixes (.log,.bin) in a particular directory (/home/username) in a one-line command. How could I do that?
0
votes
2answers
49 views

Want to edit a file content for Removing the string after the last underscore and before the file extension using Unix commands

I want to edit the file contents in the 2nd row and 2nd column ,which is a file name from that I want to remove the part after the last underscore and before the file extension . The contents of the ...
0
votes
1answer
34 views

Rename multiple files using sed command after removing the string after the last underscore [closed]

I have a set of files in a directory as shown below and I want to remove the string after the occurrence of the last underscore from it. The string may be different each time. It will be good if it ...
1
vote
3answers
56 views

Sorting filenames uniquely

I have searched for the solution but couldn't find answer to my problem. I have thousands of file in a directory. Filenames are in the below format 74687_1543944930857.txt 74687_1543945090451.txt ...
0
votes
1answer
50 views

Check that 2 arrays of file names are the same

So I have the following: cat file | grep -E regex which gives a list of lines Now I also have a for loop the produces a list of files So it is like I have 2 arrays. But how do I check in bash if ...
0
votes
2answers
51 views

Rename Files to Same Filename Without Extension with find Command

I'd like to rename a group of files to their same filename but without extension. They are scattered in my home directory and I don't know where they are located precisely, but I do know the extension ...
0
votes
2answers
56 views

How can I change lower to upper using (three) parameters in bash? [closed]

I have to make a bash script that will be changing files' names from lower to upper OR from upper to lower via parameters in command line. So when I put in command line: ./bashScript lower upper ...
0
votes
1answer
40 views

Eliminating multiple-extension file names from find output

I need to find the size of all files in /etc with the .conf extension. I tried to do this with find /etc -type f -name "*.conf" -exec du -chB1 {} +, but find gave me .conf files that have two or three ...
0
votes
2answers
33 views

delete then rename: same filenames different extensions

I have a directory containing thousands of files, each file has a duplicate. An example: file1.txt file1.jpg.txt file2.txt file2.jpg.txt I want to delete all *.txt files, and leave the *.jpg.txt ...
2
votes
1answer
33 views

Why does crc32 say some of my files are 'BAD'?

I used crc32 to compare some files with a backup of them. Out of 3556 files, 11 were reported as 'BAD' as in the following example: 9be46354 ./9836Feeding_the_dog_.mpeg BAD 9be46354 != ...
-1
votes
1answer
22 views

Rename files on QNAP linux (batch)

I have a folder with at least 30 files. The names are: 123456_12_12_AB12_NAME.mp4?BWSQv6seywG5ND2Myt7YM3JHPmaaNmtBRI0PcXbYpqoS01ivTvL0HCHvjfjFtOM9AMq7-kpHUZ0W_m8njEjqBkM9uyngsnKANw How can I get ...
-1
votes
1answer
29 views

using sed command to get after a /

I want to use sed for extracting the file name after the last occurrence of /. For example /usr/bin/file.txt and the output should be file.txt
5
votes
3answers
717 views

Remove files that start with but don't contain

I'm trying to remove a lot of files at once but need to be specific as to not remove any of the files I actually need. I have a ton of corrupt files that start master- but there are valid files that ...
0
votes
1answer
33 views

Use negate ^ to get results which not contain specified charactres

I want to grep the files whose name not containing "^iX500" $ cat note_list ... /Applications/ScanSnap Manual.localized/iX500ScanSnapManual.app/Contents/Resources/manual/basic/EN/ix500/images_mac/...
-2
votes
2answers
32 views

Handling whitespace in filepaths

I have this: muh_dir=`cd $(dirname "$BASH_SOURCE") && pwd` and yeah I tested the above (it has backticks) and it doesn't work well with whitespace in the pwd. On the other hand, this is ...
0
votes
1answer
44 views

How to find the filename without path?

Currently, I have a function to find the filename, size and type; however, it includes the path as well, which I don't really need. find . -type f -exec stat --format="%n %s %F" which returns ...
-1
votes
1answer
51 views

Create a folder with all possible combinations of characters and numbers [closed]

I want to create a folder like "example.txt, example.Txt, example.TxT... all possible combinations.
0
votes
1answer
30 views

convert a md file in odt with correct name

I added this command in Dolphin menu for convert a .md (Mark Down) file to .odt (Open Document Text ) file: pandoc %U -o %F.odt and I get the right file, but with two extension: fileorig.md.odt ...
1
vote
2answers
70 views

How to match a file name by specifying a prefix substring?

I would like to copy the files, located on a remote machine, whose filenames match a prefix string, on my local machine. I have tried to select only the files whose names start with either massif or ...
0
votes
1answer
37 views

ls: ordering by timestamp (reversed) and if the timestamp is the same order by name (not reversed)

I'd like to order a directory by reversed timestamp, but if the timestamp is the same order by name (not reversed) Using ls -tr if two files have the same timestamp order by name but in reversed mode
-2
votes
1answer
77 views

Space after filename (Linux) [closed]

Whats different "name.txt" vs "name.txt " in Linux? If I rename name.bin to name.txt - is normal and file doesn't executable. If I rename name.bin to file.txt (with space after filename) - file ...
0
votes
2answers
29 views

find specific files and copy them to a directory in linux

abc-1.0.zip kncb-1.0.zip jenk-1.1.zip I want to find all the above files dynamically and copy them to a directory except jenk-1.1.zip. I have tried the below command but it also copies file(jenk*....
0
votes
0answers
45 views

Does Fedora restrict the set of allowed characters in filenames?

According to Wikipedia's article about filenames, the set of allowed characters in a filename may depend on various things: the filesystem, the operating system, an application or interoperability ...
0
votes
1answer
17 views

Filter file to list all paths in it

How can I filter text file to remove every thing and just leave the paths in it? For example: dslkjcblasdjncklasdnlc /asdds/ads/adss/sdf.jpg asljdascuashn sdkm /sdf/dsf/dsf/dfs/sdfs.txt ,nbaskhdnasm....
0
votes
1answer
28 views

Tag files based on file name if no Title metadata exists

Is there a way using the command line to automatically fill in empty "Title" fields of the tags of music or videos with the file name? I have tried using Beets, but the only way to tag things based on ...
6
votes
2answers
440 views

Using whoami to search for files that mention user

I'm currently working through some exercises to try and improve my shell scripting. The requirements of the script are as follows: It must get the user's name using the whoami command and store ...
0
votes
0answers
23 views

Getting unique file names by specific paths only

I have a command where I get the count of all file names that begin with 2010 find folder_name/ -path '*/*/*/*/2010*' This works fine and I get valid results. However, say for instance I have this ...
0
votes
2answers
71 views

Create a new file, but add a number if the filename already exists

Is it possible to achieve this from the command line? Syntax: I can capture an image with the following command: raspistill -o image.jpg But I want to be able to run this command via cron each ...
4
votes
4answers
702 views

How do I display file names that contain two characters and one of them is c?

I tried doing ls [a-z][a-z], but it doesn't seem to be working.
1
vote
1answer
34 views

Creating empty copies of files with new extensions

I have AIX 7.1. Let's say I have a directory with files like these: 1.txt lala.csv I need to create empty copies of these files with a new extension in the same directory, like so: 1.txt.done lala....
0
votes
1answer
107 views

Creating a file named '.' and how to read and write data to it?

How would I create a file named . (dot) and read or write data to it, given that . also refers to the current directory? I know this is possible because I have a directory structure. I'm looking at ...
19
votes
7answers
2k views

Avoid listing of files that end with ~ (backup files)

My requirement is to list all files in a directory, except files ending with a ~ (backup files). I tried to use command: ls -l | grep -v ~ I get this output: asdasad asdasad~ file_names.txt ...
0
votes
2answers
34 views

How to get the filename part of a path from a shell variable

A shell variable holds a path. How does one get its filename portion? In bash(1), I experimented and found that I can do it with ."${i/*\///}" where i is the name of the environment variable. Such a ...
0
votes
1answer
41 views

Find all the filenames in this directory that do not contain 'a' 'b' or 'c' in their name [duplicate]

I am trying to find all the files in my directory that does not contain the letters a,b or c; why does this command not work? ls *[!abc]* example: eg: MATCH: xyz, dkh, file, foo; NOT MATCH: bar, ...
0
votes
3answers
62 views

Unix/Linux - Advantage of relative path names over absolute path names [closed]

I am trying to figure out what are the benefits of using relative path names over absolute path names. I know what each one is. I guess that it is easy to work with relative path names when we have ...
0
votes
3answers
87 views

Process a list of filenames to split directory and basename

I have a file containing a bunch of filenames: $ cat test_as1 /var/incoming/foo.txt /var/incoming/bar.txt /var/incoming/baz.txt For each filename, I want to print the directory name and the base ...
27
votes
2answers
2k views

Is it true that a tarball can change where files are extracted to regardless of the commands used to extract it?

I have a coworker who says you need to be careful extracting tarballs because they can make changes you don't know about. I always thought a tarball was just a hierarchy of compressed files, so if you ...
1
vote
1answer
23 views

Makefile opening in emacs, how to change?

I updated Ubuntu (technically Lubuntu) and now Makefile is opening in emacs. It used to open in leafpad. How to set it back? I checked the usual places, but I couldn't find any references in the files ...
0
votes
2answers
133 views

Grep Multiple Files with Dates in FileName for Certain range of Dates

I have a bunch of files with filenames like "Logger.2018-08-04_23:59:59.csv" and I want to grep a bunch of them at once, but only in a certain date range, e.g. 8/04-8/17. How can I do this? I tried: ...
0
votes
1answer
31 views

BashScript move files based on matching part of filenames from a list

I have millions of xml files. The name of the xml file follows this pattern: ABC_20180912_12345.xml ABC_20180412_98765.xml ABC_20180412_45678.xml From this I want to copy files to a different ...
0
votes
2answers
95 views

Significance of .bak extension in Unix?

In computing, ".bak" is a filename extension commonly used to signify a backup copy of a file. Is there any other significance of a .bak file in UNIX apart from changing the extension to .bak?
3
votes
2answers
610 views

How to delete or access a file with a backslash \ in its name?

I have some files here that I copied over to this linux box using the python module pysftp: [jm@spartan tf]$ ls -la total 0 drwxrwxrwx. 3 jm jm 69 Aug 14 13:50 . drwxrwxrwt. 9 root root 238 ...
1
vote
2answers
63 views

Changing a multiple file extension using single line command

I have some files whose names contain multiple extensions: $ ls -r File1_345.R.12345 File1_3.234.R.6789 File1_2345.R.2345 File1_12345.R.12345 $ I want to rename them to remove all the existing ...
0
votes
3answers
75 views

Unix command to remove space from a file name

I have a file whose file name has a space like First Name_20180810.csv. The date (20180810 in the above example) changes daily in the filename. How can I rename First Name_*.csv to be FirstName_*.csv?...
-4
votes
1answer
79 views

Copy the file 'red' to 'blended' directory in Unix? [closed]

Please tell me how to copy a file using relative path
1
vote
1answer
84 views

Making wget rename existing filenames sanely

When filename already exists using wget, it renames the file to filename.extension.1. Is it possible to make it rename it to filename.1.extension -- which should have been the default?
0
votes
4answers
61 views

How to sort ll output

ll returns this result: 51380224 Aug 3 08:23 tig_10.d1 51380224 Aug 3 08:18 tig_10.d10 51380224 Aug 3 08:20 tig_10.d11 51380224 Aug 3 08:23 tig_10.d12 51380224 Aug 3 08:21 tig_10.d13 51380224 ...
6
votes
4answers
512 views

Change some file names (prefix to postfix)

I have a directory containing thousands of files with names t_00xx_000xxx.png and 00xx_000xxx.png. I want to change the names of the files which starts with t_, like t_00xx_000xxx.png to 00xx_000xxx_t....