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

learn more… | top users | synonyms

0
votes
2answers
16 views

How to copy lines from multiple files into one new file and keep file name?

I have 81 files in .fasta format that contain (up to) 53 items. Such as: /User/MyData/Sample_1.fasta /User/MyData/Sample_2.fasta .... /User/MyData/Sample_81.fasta Each .fasta file contains a name ...
0
votes
4answers
66 views

Foreach loop for ls output

I am trying to process some files in directory using foreach loop for ls output: IFS=$'\n' for i in $(ls -1Atu); do echo "$i" done At first time i thought it works, but when i created file ...
0
votes
2answers
13 views

A file containing exports

I have a file containing the following: export PYTHONPATH=/home/myuser/squish-5.0-xyz/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/myuser/squish-5.0-xyz/lib I don't what to place it in my ...
2
votes
2answers
34 views

how to strip the last slash of the directory path?

I have a script which requires an directory as one argument. I want to support the two form: one is like a/b/c (no slash at the end) and another is like a/b/c/ (has slash at the end). My ...
1
vote
1answer
29 views

Bash completion - How to get filename completion for suboptions

I have a function which can take main arguments and then sub-arguments. Some of these sub-arguments are filenames. The current completion code I have is as follows. _scm() { local cur prev opts ...
8
votes
1answer
291 views

How do case-insensitive filesystems display both upper and lower case file names?

This question occurred to me the other day when I was working on a development project that relies on an opinionated framework with regard to file names. The framework (irrelevant here) wanted to see ...
1
vote
1answer
20 views

How to change configuration of detox (dash instead underscore)?

I found, best to this moment, a solution when changing all those annoying filenames in large quantities, making them readable and easier to manipulate with in command-line. So I found, among many ...
0
votes
4answers
3k views

How to match a file name suffix

How to verify if the name of a .xml file name ended with .any-string? e.g. .previous or .backup or bck12 etc ... I need to print the XML file name except for XML files that end with ...
24
votes
12answers
7k views

How can I delete a file with no name

I somehow managed to create a file that doesn't seem to have a filename. I found some information regarding how to get more details of the file in the following thread. However, I tried some of the ...
3
votes
2answers
220 views

Location of the crontab file

as many (most?) others, I edit my crontab via crontab -e, where I keep all routine operations such as incremental backup, ntpdate, various rsync operations, as well as making my desktop background ...
28
votes
2answers
778 views

find(1): how is the star wildcard implemented for it to fail on some filenames?

In a file system where filenames are in UTF-8, I have a file with a faulty name; it is displayed as: D�sinstaller, actual name according to zsh: D$'\351'sinstaller, Latin1 for Désinstaller, itself a ...
2
votes
1answer
112 views

How to list files in a zip without extra information

When I use unzip -l test.zip I get the output like this: Archive: test.zip Length Date Time Name --------- ---------- ----- ---- 810000 05-07-2014 15:09 file1.txt 810000 ...
5
votes
1answer
632 views

File name encoding wrong in KDE, but correct in GTK/tty1/

I'm on a new Linux (installed yesterday). When I access files from old partitions their file names have incorrect encoding (ä instead of ä, same for other umlauts) inside KDE apps like dolphin and ...
54
votes
6answers
9k views

How does Linux handle multiple consecutive path separators (/home////username///file)?

I'm working on a python script that passes file locations to an scp subprocess. That's all fine, but I'm in a situation where I may end up concatenating a path with a filename such that there's a ...
9
votes
2answers
4k views

Why can't I have a folder and a file with the same name?

I've never had this problem before, but for some reason, I can't rename my folder to packages/. This is the structure: root - packages_old/ - packages When I try to rename the folder with ...
12
votes
4answers
7k views

What is the maximum allowed filename (and folder) size with eCryptfs?

I am a new eCryptfs user and I have a very basic question that I wasn't able to find anywhere. I am interested in using eCryptfs via my Synology NAS that uses Linux. While trying to encrypt my folder ...
18
votes
8answers
16k views

List files sorted numerically

I have a bunch of files from log1 to log164. I'm trying to LIST the directory (sorted) in a UNIX terminal but the sort functions are only providing the format like this: home:logs Home$ ls -1 | sort ...
1
vote
2answers
215 views

Why do I have double slash here?

$ which mycommand /home/t/program_files/document/other edits//mycommand Why do I have double slash // here?
1
vote
6answers
4k views

File extensions and association with programs in linux

In windows we can associate a file's extension with programs. E.g. a file test.pl can be run by the installed Perl interpreter due to the pl extension. In linux though it needs #!/usr/bin/perl as the ...
0
votes
1answer
28 views

? appended to filename while copying from a ssh

I am using the command cp error.log error$HOSTNAME.log the command works properly while running it separately in a server, but if it is run as script which uses ssh I am getting a ? appended to the ...
0
votes
2answers
31 views

Why is wget still failing even after enclosing the URL with double quotes?

I enclose URLs I want to wget with "" since most of them have spaces, braces, etc. It usually works fine, but I can't get this URL to work: wget "http://xxxx/Sankarea - 6 - It`s Because I... Ran ...
0
votes
1answer
23 views

Standards for dealing with older/previous “.bak” backup of config file before new edit

Assume I have a config file "foo.conf." This file is rarely edited. At some point in the BeforeTime(tm) it was edited and "foo.conf.bak" was created to save the previous state. Now, I want to make ...
1
vote
2answers
71 views

Why is grep searching more than the files I want with asterisk?

Deep within a bash script I have grep -Ech 'string1|string2' /server/directory/$servername_log_20150312* | awk ... I was getting the "too many arguments" error so I turned on set -x and I see that ...
11
votes
2answers
3k views

What is the difference between “du -sh *” and “du -sh ./*”?

The title says it all. What's the difference between those 2 commands? NOTE: I'm more interested in the * and ./* part.
1
vote
1answer
45 views

Create tar files from shell script with current time stamp

I am trying to create a shell script which will back up my git codebase and save in a specific back up directory with current days name So far I have : #!/bin/bash branch="master" if [ $# -eq 1 ] ...
3
votes
3answers
44 views

Find command: multiple conditions

As a standard for my file/dir naming I use something like putting date and tags string into the file name separated by underscore, eg: 2015_03_10_usa_nyc_vacations_album_pictures For a long time I ...
6
votes
2answers
656 views

Use of file names ending with a period

Why does Unix allow files with a period at the end of the name? Is there any use for this? For example: filename. I am asking because I have a simple function that echoes the extension of a file. ...
2
votes
2answers
107 views

How to rename thousands of files efficiently?

I have a bunch of music files (literally thousands of files) in my Fedora PC that I'd like to rename with two rules: Every space must be replaced by the character _ (underscore), and Every letter in ...
1
vote
1answer
35 views

Batch rename “case duplicates”

I have a folder on my Linux system that is cross-synchronized with other computers, some of them with Windows. The problem is that in that folder there are files that are "case duplicates", i.e. their ...
16
votes
4answers
26k views

File extensions for unix shell scripts

On wikipedia, the article for .sh says: For the .sh file extension type, see Bourne shell. How about other unix shells? I know that the shebang is used inside the file to indicate an ...
1
vote
2answers
81 views

Search for matching files with wildcards without using find in a bash script

For an assignment, I'm supposed to write a bash script that can act as a very basic find, but without actually using the find command. For example, if I put in this input: my_find ~/homedir/ -name ...
1
vote
2answers
82 views

Extracting numbers with a decimal point from ls output in Bash

I would like to extract the numeric part of the file names that begin with "hsli" and end with ".h5" in Bash on Ubuntu 14.04.1 64-bit LTS. My ls -l hsli* output is as follows: -rwxrwxrwx 1 ongun ...
0
votes
0answers
6 views

CAJA: make all files with a given suffix get a given file type

Currently, my files with the suffix (extension) .def are recognized as generic "plain text files", and are opened in gedit, which I prefer for plain text files. However, my .def files are actually a ...
1
vote
2answers
101 views

for loop when matching both front and back of file name

I'm trying to set up a for loop to run a process on pairs of files. The names of the files look like this 36_002_CGATGT_L001_R1_005.fastq.gz 36_002_CGATGT_L001_R2_005.fastq.gz ...
3
votes
3answers
188 views

display filename followed by content without interaction

My program writes it state to few files every 30 seconds or so (overwrites) and I would like to look at them with the filenames displayed like "more" does. Like: $ echo 1234 > test00 $ echo 5678 ...
2
votes
2answers
87 views

remove the low version number of file

I have these files: atk-2.8.0-ia64-11.31.depot gtk+2-2.24.25-ia64-11.31.depot lzo-2.09-ia64-11.31.depot bash-4.3.030-ia64-11.31.depot gtk+3-3.6.5-ia64-11.31.depot ...
0
votes
2answers
44 views

find {} returns the full filename but I just want the filename without the extension, so index.md would return index instead of index.md [duplicate]

So I have find . -name \*.md -type f -exec pandoc --filter ./filter1.py -o {}.html {} And notice the {}.html. The {} returns a filename ending with .md, but I want it to just return the filename ...
0
votes
3answers
75 views

Running sh file only works if cd'd to scripts directory

I'm trying to run a .sh file, through the ./file.sh syntax. I, wrongly, thought it'd be possible to run: ./usr/bin/foo/bar.sh which just yields "No such file or directory". However, if I run: cd ...
3
votes
1answer
62 views

How do you get the first file in each subdirectory matching a list of file extensions?

How do you get the first file in each subdirectory matching a list of file extensions? My goal is to run a program on just any one of the files in a series of subdirectories. For example, below ...
2
votes
1answer
28 views

Unix Filename ignore list [closed]

We are trying to set up Unix based server and we are trying to figure out if there is any way to forbid creating certain files on the server. I mean files like: .DS_Store, .BridgeCache, ...
6
votes
4answers
10k views

Split a file by line and have control over resulting files extension

There is a standard command for file splitting - split. For example, if I want to split a words file in several chunks of 10000 lines, I can use: split -dl 10000 words wrd and it would generate ...
0
votes
2answers
52 views

Unix how to loop through directories, send output to another directory with base name of input file

I am an infrequent user of UNIX, I'm sure this will be fairly trivial for any regular user so I appologize for that. I have the following code: for file in /home/sub1/samples/aaa*/*_novoalign.bam ...
1
vote
0answers
57 views

Rename files with non-utf8 characters using detox

I am trying to use detox in the following way detox -s utf_8-only -r -v -n to detect invalid filenames on my system. The command performs mostly ok. Unfortunately it falsely detects also German ...
1
vote
4answers
67 views

Dynamically reference a file's name

In a single directory, I'd like to replace the first line of each file with the file's name. Each file has as the first line "TestRelation." I'd like to replace it with the file's name. I know I can ...
3
votes
0answers
32 views

How do I safely get multiple filenames from Zenity?

Zenity can be used to create a file selection dialog and select multiple paths. The separator for paths is specified using the --separator option. Therefore we can't use NUL, the only safe character ...
1
vote
2answers
173 views

How to handle spaces in path names when variable contains multiple paths [duplicate]

Although I've read myself through most of the questions about handling spaces in path names, I haven't found my case yet, which is about several path names in one variable. find will need this when ...
3
votes
3answers
106 views

The output I get via “echo” works as a command when pasted to terminal, but not in the script

I'm trying to change the files generated by an app that unfortunately often contain spaces. I have managed to get "echo" to give me output that works if copy pasted into terminal, but when I try to do ...
-4
votes
2answers
68 views

how to find a file extension with multiple dots [duplicate]

I'd like to extract the extension out of a filename with multiple dots. For instance: gbamidi-v1.0.tar.gz I should get "tar.gz", not "gz" or "0.tar.gz". I prefer a solution not relying on bash ...
10
votes
5answers
865 views

How to get the last N files in a directory?

I have many files that are ordered by file name in a directory. I wish to copy the final N (say, N=4) files to my home directory. How should I do it? cp ./<the final 4 files> ~/
1
vote
1answer
264 views

Why has '-' been chosen as the backup file suffix for certain Unix system files?

Example: /etc/group-, /etc/passwd- Is there any motivation behind choice of the - sign (e.g. easier to recognize, process, etc.)?