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

learn more… | top users | synonyms

0
votes
5answers
146 views

how to extract part of a filename before '.' or before extension

I have files in format below: abc_asdfjhdsf_dfksfj_12345678.csv hjjhk_hkjh_asd_asd_sd_98765498.csv hgh_nn_25342134.exe I want to get the value before the . and after the last _. The result would ...
6
votes
5answers
339 views

Renaming files with its path name

I have a .bdf file inside subfolders. All the .bdf have the same name: Loads.bdf Example: /home/user/folderxx/folderxxx/Load.bdf /home/user/folderxx/folderxxx/Load.bdf I need to find (and copy to ...
1
vote
2answers
214 views

tar compression without directory structure

Under my current directory, I have two sub-directories: dir_1/ - file1.png - file2.png ... - fileN.png dir_2/ - fileA.txt - ... - fileZ.txt When I tar compress the two ...
1
vote
1answer
91 views

Globbing with * in Bash - Debian vs RHEL [closed]

Where is the difference? Do these distributions handle globbing differently? Platforms: Debian Wheezy 7, Red Hat Enterprise Linux 7. Bash is always used. In my example, cat prints every file in /etc ...
3
votes
2answers
1k views

Extract file name from path in awk program

I have an awk script and I have passed a CSV file to it. awk -f script.awk /home/abc/imp/asgd.csv What am I doing is to get FILENAME within script.awk. FILENAME gives me the whole path. As I am in ...
0
votes
2answers
47 views

How to create a variable $ldir at your home directory that contains the relative path to letters?

If there's a directory on your Desktop called letters: 1) How to create a variable $ldir at your home directory that contains the relative path to letters? 2) How to copy a text file f1.txt to the ...
3
votes
1answer
109 views

How to find all paths not compatible with Windows?

On most Linux filesystems, NUL (\0) is the only invalid character in paths (and / is reserved as the path separator). Windows has a complicated set of rules for valid paths. Rather than fixing paths ...
1
vote
3answers
88 views

Copying the full path of a file to text file

I want to get the full path of all files in a directory and and the entire path has to be saved in one text file. Can you give me the script for that?
2
votes
1answer
156 views

mapping a split file to /dev/loop0

I have a iscsi disk 2TB large. I make backup of that disk every week. The backup script copies the image of the whole iscsi disk into a file on my NFS. Unfortunately, it does not copy the image in one ...
1
vote
1answer
717 views

Using EXIFTool to add EXIF data from filenames

There is a set of photos with timestamps in their filenames like these: Photo on 3-09-12 at 9.24 PM #2.jpg Photo on 3-09-12 at 9.24 PM #1.jpg Photo on 3-09-12 at 8.23 PM.jpg etc. ("3-09-12", ...
2
votes
3answers
82 views

Make grep work for special filenames

I have a set of txt files whose names may contain space or special characters like #. I have a grep solution grep -L "cannot have" $(grep -l "must have" *.txt) to list all the files who have must ...
2
votes
1answer
53 views

How to list files in a zip without extra information

en 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
6answers
593 views

About the .file and ./directory confusion

This is a dumb question, but I recently moved from windows to linux, and I see one strange thing: ./configure or nano /something/something2 Is this something2 a file? It looks like a directory, ...
-1
votes
1answer
72 views

What does ~ mean at the end of a file name (e.g. httpd.conf~)? [duplicate]

I edited a fresh apache config file in CentOS 5 using gedit. When I looked at the directory I saw now two files: httpd.conf and httpd.conf~ What does the ~ signify?
-1
votes
2answers
136 views

Split files and rename the files

I need to split a large file into 5 pieces and rename them. For Example, file Test needs to be split into Test1, Test2 & Test3. However, the split command splits as xaa,xab,xbc.
-2
votes
2answers
58 views

changing the names of files within a directory [duplicate]

I have few files under a particular directory. These are the files idex.1.ebwt idex.2.ebwt idex.3.ebwt idex.4.ebwt idex.rev.1.ebwt idex.rev.2.ebwt I want to change the names of the file from ...
1
vote
2answers
4k views

How do I get absolute path from using find unix command

How to get absolute path by using find command. actually I am running the following script:- find . -size +20M | while read a do i=$(echo $a | sed 's:/: :g') echo $a; j=($i) ...
3
votes
2answers
331 views

Path syntax rules

I'm writing a library for manipulation Unix path strings. That being the case, I need to understand a few obscure corners of the syntax that most people wouldn't worry about. For example, as best as ...
2
votes
1answer
31 views

What is the meaning of '.' in the cpio file

This is my the content of my rootfs.cpio file: [root@xilinx output]# cpio -idv < rootfs.cpio . init dev dev/console 1149 blocks What is . here ?
4
votes
7answers
563 views

How to split a filename list in 5GB sets?

I have a pretty big list of files which I like to group in smaller list of 5GB each for further processing. The file list is in the following form: "size" (from du) "tab" "absolute path", like this ...
2
votes
2answers
137 views

Shell Scripting: how to use part of the file path as the file name?

I have a group of directories, each containing exactly 1 jpeg image, like so- /psds/folder1/image.jpg /psds/someotherfolder/picture.jpg /psds/yetanotherfolder/thumbnail.jpg What is the appropriate ...
3
votes
3answers
122 views

Change the name of a file that contains spaces in the name

I don't know why but when I go to change this file name with mv command it comes up with the error stating not a directory. -bash-4.1# mv {{ THEME SANITIZED }}.hacks.css myomega.hacks.css
1
vote
0answers
142 views

How to use fslint (in particular findnl) on the command line to actually mimic the behavior of the fslint-gui?

So I am trying the fslint tools. However, the help included in those tools as well as the man page don't indicate that the cleanup actions offered by the fslint-gui are also available through fslint ...
2
votes
2answers
219 views

grep and directories containing spaces

I would like to search all files containing an association of strings (here the files should contain 'arthur' AND ('déni' OR 'deni') for instance) in a directory and subdirectories. After some search ...
1
vote
1answer
193 views

cp /etc/DIR_COLORS ~/.dir_colors not responding

I'm using CentOS 6.5 and Putty. My problem is that directory file names are shown in dark blue color which is hard to read. I google searched and found this link; basically it's copying the DIR_COLORS ...
1
vote
1answer
79 views

Command works with tilde at the end. How?

I'm on Ubuntu. I have a script called myscripts in /usr/bin/myscripts This script simply changes the current directory to ~/Work/MyScripts Normally, I simply open a terminal and type ~/Desktop$ . ...
3
votes
3answers
6k views

Why can't find -regex match a newline?

Why does this fail? touch "$(printf "a\nb")"; find . -regex './.\n.' I also tried these, none of which work: find . -regextype posix-extended -regex '.\n.' find . -regextype posix-awk -regex ...
3
votes
4answers
443 views

Use basename to parse a list of paths held in a file

I'm running Mac OSX and trying to use the command line to find the number of files I have with the same name. I tried to use the following command: find ~ -type f -name "*" -print | basename | sort ...
2
votes
1answer
600 views

Find out if files in a folder exist under other name in other folder

Possibly a little incorrect English ahead: There are at least 2 folders. For this, A contains files without extension, usually usernames, and B contains similar files, with '.yml' extension or ...
1
vote
7answers
353 views

what are some uses of .(single period) & ..(double period) in the shell command line

The single period . means current working directory The double period .. means parent of the current working directory I can only think of . being used in relative pathname etc cd ./bin/usr How are ...
3
votes
4answers
419 views

How to sort a list of files by time, given only the filenames

Given a list of file names, how can I sort it by file modification time? The resulting output needs to look exactly like the input with the exception that the data has been sorted accordingly. Here ...
3
votes
1answer
132 views

Make Linux forbid colons in file names on NTFS partitions

Does Linux really allow colons in file names, even on NTFS partitions? Why is that? And is there any option to set it straight, and do not allow colons (and other characters restricted by Windows) in ...
1
vote
3answers
69 views

Append to the name of each file in directory [duplicate]

How to append “.backup” to the name of each file in your current directory?
0
votes
2answers
150 views

Handling files with whitespace in their names

I have a lot of files that I need to sift through, specifically grep for certain keywords IN THE FILE, not he FILENAME. I have some 300+ files on a filesystem (so the files are within multiple ...
1
vote
2answers
241 views

How to batch clean filenames containing invalid characters

I have a larger directory with files whose filenames contain special characters such as line breaks. The origin of these characters is seemingly that I copied and pasted text from within pdf files ...
8
votes
1answer
260 views

Can I truncate long file names in ls listing

I have a number of files with very long names. Please, is there a way to use ls -C and truncate the file names to get more columns for an overall view? Or is there a better way to get a compact ...
2
votes
2answers
509 views

Extracting parts of filename

I'm trying to use a part of the file name to be inserted into a new file created using the script. For eg: dcn_2014_01_31_14_17_45_505.pcap and dcn_2014_01_31_14_32_27_656.pcap should give ...
2
votes
2answers
436 views

How do I check that a filename conforms to a pattern?

I'm tasked with writing a shell script which checks that a filename conforms to a specific pattern and I'm not sure how to go about it. The filename should follow a pattern which looks like: ...
11
votes
2answers
2k 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
2answers
112 views

Keeping the latest two version and delete the remaining

I have a list of files (say xsl format below) in one directory. I want to keep the last two version of all files. (I can delete the remaing files) {A}_1.0.xsl {A}_2.0.xsl {A}_3.0.xsl {A}_4.1.xsl ...
9
votes
3answers
2k views

identify files with non-ASCII or non-printable characters in file name

In a directory size 80GB with approx 700,000 files, there are some file names with non-English characters in the file name. Other than trawling through the file list laboriously is there: An easy ...
0
votes
1answer
59 views

Files with “core” name

Can I be sure that files with name core on the system are core dump files? Or how can I be certain about some files that they are core dumps to delete them? (best practices are welcome)
12
votes
2answers
656 views

Shell filename pattern that expands to dot files but not to `..`?

Recently I had a little mishap caused by a shell pattern that expanded in an unexpected way. I wanted to change the owner of a bunch of dot files in the /root directory, so I did chown -R root .* ...
6
votes
2answers
506 views

How does GLOBIGNORE work?

According to bash's manual page: GLOBIGNORE A colon-separated list of patterns defining the set of filenames to be ignored by pathname expansion. If a filename matched by a ...
0
votes
3answers
555 views

Identify if files or directories are hidden

I am trying to write a bash script that prints out all files (including hidden) in a directory recursively and records the number of files, hidden files, hidden directories and directories. This is ...
8
votes
3answers
147 views

POSIX compliant way to work with a list of filenames possibly with whitespace

I have seen Bash scripting guides suggesting the use of array for working with filenames containing whitespace. DashAsBinSh however suggests that arrays are not portable so I am looking for a POSIX ...
6
votes
3answers
150 views

How can I determine a file's conventional filename extension

The file command is good at determining file types for my needs. Is there any way to map those results to conventional filename extensions?
2
votes
1answer
423 views

Mouse shortcut to copy the path to a file in the Gnome file manager

Is there a Linux equivalent of the Windows Shift+Right-click sequence? I use this a lot on files and directories to get the 'hidden' "Copy as path" option in the pop-up menu. It saves a lot of ...
0
votes
0answers
101 views

Shell Script : Check for all the source files in different paths

This is the naming convention of the file. <yearmonthdate>_<sourcesystem>_<totalnoofpartsof file>_<subject area>_<part number>.dat (or .dat.gz) First part is Date, ...
3
votes
6answers
537 views

How to delete a NTFS filesystem file whose name contains “:”?

I backup some of my Linux files in a NTFS removable hard disk several days ago, this time I need to remove those files. But I find it difficult since: On windows, it complains that "Could not find ...