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

learn more… | top users | synonyms

2
votes
4answers
92 views

How to delete a tilde (~) folder? [duplicate]

I need to delete a "~" folder in my home directory. I realize now that rm -R ~ is a bad choice. Can I safely use rm -R "~"?
2
votes
1answer
43 views

Change to a directory containing a space

I'm using a MacBook with OS X installed. I'm on Terminal trying to go to a directory. So I'm in Home and I use the command ls and there is a VirtualBox VMs directory. But when I try to do cd ...
3
votes
1answer
50 views

Is there a way to use regex expressions to auto-fill filenames in bash?

Assuming I have a directory with files as shown: $ ls file0001.txt file0002.txt file0003.txt file0004.txt file0005.txt someotherfile.txt Lets say I want to run the following command: $ cat ...
1
vote
0answers
22 views

How to remove a single quote from a file name? [duplicate]

I have some podcasts on my radio server which contain a timestamp when they should be played. I noticed one of them is put into single quotes 'filename.mp3', and I'm unable to remove them. Check this: ...
0
votes
2answers
61 views

Are periods (“.”) valid characters in file or folder names? [closed]

I would like to name my files and folders according to a specific date, e.g. 03.04.2016. I see I can use them but are there any disadvantages to using periods in files or folder names?
2
votes
0answers
22 views

Producing the next available filename for a pattern (02-output.log etc)

I can use mktemp(1) within a shell script to make a temporary file in a directory with a suitable suffix & prefix. Is there a command that, given a pattern (e.g. NN-output.log) will look for ...
1
vote
2answers
26 views

How prepend appropriate amount of 0's to numbers contained in image names?

I've got a folder /User/me/Desktop/folder/images with files like key 1--name.jpg, key 10--name1.jpg, etc. The files are sorted incorrectly when fed to my site so I get an arrangement like key ...
1
vote
3answers
49 views

Get directory name from file name

I want to make a directory name by extracting parts of a file name. Here are some examples: server.log.2016-03-20-14 → 20160320 server-2016-03-17-13-16-Restart.log → 20160317 I'm using HP-UX.
0
votes
2answers
52 views

Transforming a list of files separated by new lines into a variable

Goal: I'm trying to find all instances of *.clj or *.cljs files recursively within a directory, store them in a string variable (separated by new lines) and then transform them. So if the following ...
3
votes
2answers
160 views

Why the defined path is used as file name when I transfer files through scp to a Windows host?

When trying to copy a file from Linux (Raspbian to be precise, though I don't think it matters) to Windows using SCP: scp a.txt {user}@{ip}:\C\Users\{user}\a.txt The file is copied, but to ...
1
vote
1answer
51 views

Characters best avoided in filenames when used in Bash, e.g. `?`

For example: $ ls -l total 344 -r-------- 1 t t 145657 Mar 11 01:53 joeltest-slides.pdf -rw-rw-r-- 1 t t 166814 Mar 11 01:55 The Joel Test: 12 Steps to Better Code? by Joel Spolsky.pdf drwx-w--w- 2 ...
22
votes
8answers
1k views

Clipboard for copying and pasting files in command line?

In Bash, suppose I visit a directory, and then another directory. I would like to copy a file from the first directory to the second directory, but without specifying the long pathnames of them. Is it ...
12
votes
5answers
950 views

How to list all files in a directory with absolute paths

I need a file (preferably a .list file) which contains the absolute path of every file in a directory. Example dir1: file1.txt file2.txt file3.txt listOfFiles.list: ...
3
votes
2answers
45 views

How to pin certain files when using sort?

Normally I am more creative with Unix commands and pipes, but not today. So what I have is this: collage.jpg DCIM001.jpg DCIM002.jpg or this: 001.jpg 002.jpg boston-collage.jpg or sometimes ...
-1
votes
4answers
133 views

Why does linux use file extension to decide the default program for opening a file though it's independent of file extensions

I have a text file as- abc.text and it has its contents as Hi I'm a text file. If I double click to open this file, then the files is opened in gedit editor. Whereas, if I rename the file to ...
1
vote
2answers
57 views

How to extract a string from a file name?

I'm trying to read a part of a file name to make it in an if .. else statement for example : file name : foo_bar_test1_example.stat I want to do a test; if the word : example exists in the file ...
1
vote
0answers
71 views

How can I switch from one user to another user inside a script?

.The issue is my id 'aaa' can read only the file name and not the contents inside it when I log in with my id "aaa". So to read the contents I have to switch to another user "bbb" which is having ...
2
votes
3answers
158 views

Find and rename files (including directories) whose filenames contain space [duplicate]

I have quite a number of files and directories with spaces in their filenames in my ext4 filesystems. How should I safely find and rename them? I have bash and am running Ubuntu. Is it possible ...
0
votes
1answer
44 views

Unable to move files having spaces in their name [duplicate]

I want to move files from one folder to another folder, my code is working fine when file name doesn't contain spaces but if there is a space in a file name then I am getting an error My Code is as ...
3
votes
3answers
41 views

Ignore spaces in for Loop while printing file name?

I am trying to get files having size greater than 1k and with an txt extension my code is as follows : files=$(find foldername -size +1k -name \*.txt -exec {} \;) for item in $files do echo $item ...
0
votes
0answers
22 views

Forced search on specific folders in file manager

I am running Arch using XFCE as a DE. I currently have Thunar as my file manager but I have installed Gentoo and Xfe remotely so I am waiting to have a look at them. My question is: in some file ...
0
votes
2answers
30 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 ...
5
votes
1answer
87 views

How to fix file name encoding

I scrapped a site with wget. That site is in German and some of that pages had Ü,ü,Ö,ö,Ä,ä,ß in the URL. Now some files have a very weird name. For example one file is called ...
1
vote
1answer
40 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
54 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
100 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
24 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 ...
74
votes
9answers
5k views

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
401 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
42 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
269 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
35 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
717 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
117 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
34 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
34 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
168 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
76 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
659 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
166 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
71 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 ...
1
vote
2answers
47 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
57 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
446 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
47 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
92 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
101 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
84 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
58 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??
19
votes
7answers
3k 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 ...