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

learn more… | top users | synonyms

1
vote
1answer
30 views

Remove a part of a path from a variable content

In a Bash I have a variable: LOCAL_PATH="/this/is/a/path/" Then I have another variable, which content starts with LOCAL_PATH and it should be removed: LINE="/this/is/a/path/which/is/longer" The ...
1
vote
2answers
38 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 ...
5
votes
1answer
46 views

How to decompress files from an archive ignoring the file names?

I have several ZIP and RAR archives where the filenames inside the archive are scrambled and they contain invalid filesystem characters like ?-s *-s or !-s or very long file and directory names that ...
0
votes
0answers
21 views

how to find (,put in folder) and relink to post: pictures moved to other directories

I have some 24000 pictures that have been mistakenly scattered into different directories under one top directory (upload). Now I have broken links in (wordpress) posts that were linking to these ...
73
votes
9answers
5k views
+100

On what systems is //foo/bar different from /foo/bar?

Throughout the POSIX specification, there's provision (1, 2, 3...) to allow implementations to treat a path starting with two / specially. A POSIX application (an application written to the POSIX ...
3
votes
7answers
321 views

Check if shell variable contains an absolute path

I want to check if a shell variable contains an absolute path. I don't care if the path exists or not—if it doesn't I'm going to create it—but I do want to ensure that I'm dealing with an absolute ...
0
votes
0answers
30 views

What is the purpose of .been_here file?

I was browsing the files under .quickinstall when I located this file. It looks bit suspicious! The file, located at ~/.cpanel/quickinstall only says "I've been here".
8
votes
4answers
180 views

dirname and basename vs parameter expansion

Is there any objective reason to prefer one form to the other? Performance, reliability, portability? filename=/some/long/path/to/a_file parentdir_v1="${filename%/*}" parentdir_v2="$(dirname ...
1
vote
2answers
23 views

How to change the default use of detox, so it just doesn't replace spaces by underscores

I'm happy with the default usage of detox for sanitizing filenames, except I don't always want to replace whitespace with a single underscore. Would like to replace whitespace with a single space. ...
3
votes
4answers
468 views

Copy All Files With Certain Length File Name

In directory /source I'd like to copy all files with a file name more than 15 characters to directory /dest. Is there a UNIX command to do this? EDIT: Although this question explains how to search ...
2
votes
2answers
81 views

List of filenames as argument for mplayer => mplayer doesn't recognize the filenames

i want to play some music files with mplayer randomly. I don't want to switch the player for that, i want to understand what's wrong here. ThePandaTooth $ ls file_1.ogg file_2.ogg file_3.ogg I ...
0
votes
0answers
26 views

Kali Linux 2.0 File language

does someone know how to change folder names (Documents, Templates, Desktop etc.) I installed it in Croatian and change the language into English (US). Everything works and is translated except for ...
2
votes
2answers
33 views

rename of file extension doesnt work [closed]

I'm using code like the following to create a logfile using the shell's string manipulation tools: I have a file name and, in the case of an error, I need to create a log file with the err. Suppose ...
3
votes
2answers
130 views

How do I remove all but the file name (with no extension) from a full file path? [duplicate]

I am presently writing a Bash function to convert all the man pages listed by equery files <PACKAGE> | grep /usr/share/man/man (if you are unfamiliar equery is a tool used on Gentoo-based ...
1
vote
4answers
69 views

Avoid the contents of a .tar begin with './'

I want to make a backup of a directory using tar and xz, but I have a problem. When I open the file, all the files and directories begin with ./ and I don't want this to happen. file.tar.xz |---- ...
5
votes
3answers
646 views

File name beginning with - (dash) [duplicate]

I have file called -l in my directory now I tried to do for i in *; do stat -c "%s %n" "$i"; done it lists all files with sizes but in the middle of the output there is something like 395 ...
2
votes
1answer
83 views

ksh: for loop to loop through files in a particular directory

schema_dir=schema_app for SCHEMA_CHANGE in $schema_dir/* do so my pwd is /A/B/C/scripts within which I have subdirectories (schema_app, schema_data, etc). I want a for loop to run through the files ...
-1
votes
1answer
67 views

Shell -Bash using Unix

Hey i need to find file name which has different parts in its name and extension which is is located in the given directory Example- part1_part2_part3.h partx_party_partz.h ...
2
votes
2answers
42 views

How to extract first part of filenames with same suffix?

I want to get at the prefix of a variable-length filename. In: some_filename_123-uniq.tar.gz Out: some_filename_123 In: some_filename_1-uniq.tar.gz Out: some_filename_1 This does the exact opposite ...
1
vote
1answer
36 views

Create file for every result of find command?

With this line of code I generate an output of every result. exec("find ics/ -mmin +3 -type f -name '*.pdx' -exec basename {} ';' > ./tmp/filename") How can I generate a file with dynamic file ...
5
votes
2answers
439 views

How do you call the “happy-dog” part of file “happy-dog.png”?

I just realized I don't know how file is called in file.ext. The whole file.ext is called a file or filename, ext is called extension but how do you call the file part itself of file.ext? For ...
0
votes
1answer
45 views

quoting problem when piping find output into xargs [duplicate]

I have a directory with the following subdirectories, i.e. If I run $ tree -L 1 . ├── 2007-06-20_to_2008-10-01 ├── 2008-07-21_to_2008_08_12-Nokia 2mp ├── 2009-11-01_to_2011-01-10 - All iphone Pics ...
2
votes
0answers
49 views

some cyrillic file names got broken after moving from server to server

I moved my website from one server to another and encounter a problem with cyrillic filenames. Some cyrillic URLs in wordpress are fine and some are now broken. It used to be OK on previous server. ...
2
votes
1answer
65 views

Creating a symlink with a colon in the name on cygwin bash

I'm using bash, version 4.3.42(4)-release (i686-pc-cygwin) on cygwin. I want to create a symlink C: -> /cygdrive because a vagrant build process has that file path specified. The vagrant script has ...
1
vote
1answer
64 views

Extracting filename from path string

I have requirement to extract the filename from a given path for e.g. /dev/user/test.csv. I need location /dev/user/ in separate variable and file name test.csv in different variable. Could someone ...
1
vote
5answers
43 views

can't remove file with carriage returns

I have a file blahblah\r\n.txt that I want to remove but rm blahblah\r\n.txt does not work as I receive No such file or directory message. How to remove??
18
votes
7answers
2k views

Is it considered a best practice to not use capital letters in file naming?

People say you shouldn't use spaces in Unix file naming. Are there good reasons to not use capital letters in file names (i.e., File_Name.txt vs. file_name.txt)? Or is this just a matter of personal ...
0
votes
2answers
35 views

Does soft linking a directory hard link its subfiles?

Suppose I have the following configuration: Folder A file1 file2 I then create a soft link of Folder A as follows: ln -s A B so that we now have: Folder A file1 file2 Folder B ( symlink of ...
2
votes
1answer
17 views

How can I delete a former MTP directory, which now gives me input/output error whenever I try?

I have ~/srv/mtp, which I do not remember how I created. It was back when I was trying to set up a MTP mountpoint using various tools for that. Currently I can't do anything to the directory. ○ file ...
2
votes
3answers
102 views

How to search for text within compressed files and get just the files name

I'm trying to find just the files' names which contain an specific string. The files are compressed (.gz). I don't have zgrep installed and can't install it. Therefore I can't use the -l option. ...
6
votes
2answers
350 views

Is it possible to fake a specific path for a process?

I'm trying to run ADB on a linux server with multiple users where I am not root (to play with my android emulator). The adb daemon writes its logs to the file /tmp/adb.log which unfortunately seems to ...
1
vote
1answer
21 views

Scan though directory of files and find replicates with same name and concatenate them into one file

I have a directory with a bunch of files For example: ExperimentA_Rep1.bed ExperimentA_Rep2.bed ExperimentA_Rep3.bed ExperimentB_Rep1.bed ExperimentD_Rep1.bed ExperimentC_Rep1.bed ...
3
votes
3answers
86 views

Why are square brackets preventing shell expansion?

'4800483343' is a directory, and 'file1' & 'file2' are two files in it. Why is the following happening? $ ls 4800483343 file1 file2 $ md5sum 4800483343/* 36468e77d55ee160477dc9772a99be4b ...
5
votes
4answers
223 views

How to find missing files with sequential names?

I have thousands of files named 1.txt 2.txt and so on. Some of those files are missing. Which would be the easiest way to find out which files are missing?
3
votes
3answers
98 views

Using basename to strip file extension and search for files with the same name

Basically, I have a folder /test/ that has a number of files of type .doc and .pdf. Some of the files have a .pdf and a .doc version, such as test.doc and test.pdf while others only have one version. ...
0
votes
1answer
93 views

SED find and replace element in filename with incremental values

A sample filename is Sample-0.0.1-SNAPSHOT.jar (result of a maven build in jenkins). My goal is to run a shell script that executes on failure and what that script does it adds incremental numbers to ...
3
votes
2answers
76 views

How can I remove files which contain special characters and Latin-1 characters?

I have 2 files in a directory named App on my Ubuntu mahcine. I want to remove those 2 files completely from that directory, but when I try to remove them using rm -rf, they are not deleted. I can't ...
2
votes
1answer
111 views

Using rename command to rename first part of a file

I have three files in a directory (in mac-osx terminal) say INIT_Struc1 INIT_Struc2 INIT_Struc3 which I need to rename as FINAL_Struc1 FINAL_Struc2 FINAL_Struc3 When I use the rename command ...
2
votes
2answers
68 views

Remove specific (known) extension from filename if it's there

I'm not even sure whether grep is meant to be used for regex in one-line data. Googling led me to this lookahead expression that, along with grep, matches any .ext file and returns bare name: ...
3
votes
2answers
276 views

Regex file name with multiple digits

Say I have the following file: test_file-1234-master.tar.gz I have tried to un tar using the following commands tar -xf test_file-[0-9]+-master.tar.gz tar -xf test_file-[:digit]-master.tar.gz ...
3
votes
2answers
102 views

How are log files named?

Or what can we infer from the names of log files? For example, when I want to check the Xorg logs, I find three files: Xorg.0.log Xorg.0.log.old Xorg.1.log You can also find many such log ...
0
votes
1answer
26 views

Find filename using list inside a file

How can i find all filenames that match a string in a list inside a file? I have a list_file.txt with a list of email addresses each in a new line like this: 1@mail.com 2@mail.com 3@mail.com ... ...
0
votes
1answer
575 views

Using a relative path? I know the absolute path. Using copy command? [closed]

I have a lab I am doing for a Linux Operating class. The question I am stumped on is: For the following questions, only use the cp command to copy files. You should currently be inside your ...
2
votes
1answer
49 views

To which files does the key stroke and mouse click data go first and what form they have?

I want to know which files belong to keystrokes and mouse clicks, and what kind of data is sent to them. My main purpose of asking this question is key logging. I want to write a key logger script ...
1
vote
1answer
107 views

What characters are valid to use in filenames? [duplicate]

I seems like it is possible to create filenames in unix with just about any valid character. touch \; && touch \\ && touch \" && touch $'\n' && touch $'\t' && ...
3
votes
1answer
130 views

How does Linux detect mime type? [duplicate]

I have a PDF file with extension .pdf. If I remove .pdf - the file is still recognized as PDF file ($ file sample - output sample: PDF document, version 1.4.) What is the mechanism of filetype ...
0
votes
1answer
12 views

Obtain filepath of directories containing a particular filetype in alphabetical/numerical order [duplicate]

I have a directory that contains 800 subdirectories named disp-001 ... disp-800. All these sub-directories need to contain a specific file say stdout. One among them does not contain the file and I ...
5
votes
1answer
282 views

Untar filenames in a character encoding different from encoding used in the filesystem

I occasionally get tarballs where the filenames are encoded in ISO-8859-1 or some other pre-Unicode scheme. My system uses UTF-8, so when I untar these archives with the usual options (tar xvf ...
0
votes
2answers
69 views

File System that supports duplicate directory names

Is there a file system that supports duplicate directory names. Ideally to distinguish between directory names you would use indexes(file directory order). This is related.
4
votes
1answer
63 views

Using File Date/Time as Metadata: Reliable?

Background: I have groups of files in their own directory which I merge into one file in order of their filename. I call them t1.txt, t2.txt, t3.txt... I merge them in order of the integer. ...