Home > bash > filename start with *

filename start with *

February 1Hits:0

I've got script, it must go through files to get specific lines from them. Filename get from variable, for example $FILENAME and we've got such situation:

cat /path/$FILENAME

but when FILENAME==*.some.file there is a problem. File *.some.file really exist, but cat lists all files by mask *.some.file (first.some.file second.some.file *.some.file fourth.some.file and so on) single quotes on path prevent include of variable.

Any ideas how to cat (or grep) only one *.some.file?


Use double quotes. This will expand the variable, but not any embedded wildcards.

cat /path/"$FILENAME"

cat "/path/to/$FILENAME"

will not expand * to a glob.

cat \*.some.file will escape the * so it's treated as a literal character.

Also cat '*.some.file' will have a similar effect. In both cases, it prevents bash from expanding the * to a list of matching files.


Related Articles

  • How can I open a file that has a Chinese Filename in C? December 28

    Is there a standard way to do an fopen with a unicode string file path? --------------Solutions------------- In *nix, you simply use the standard fopen (see more information in reply from TokeMacGuy, or in this forum) In windows, you can use _wfopen,

  • Using XCACLS to set permissions with long filenamesMay 12

    We need to set permissions on users' directories on a Windows 2000 Server. This happens regularly enough and they must also be set in the order below or the backups crap out. This is the basic script: XCACLS foldername /g Administrators:OF /T /C /Y X

  • Filename length limits on linux?May 18

    Are there any filename or path length limits on Linux? --------------Solutions------------- See the this wikipedia page about file systems comparison, especially in column Maximum filename length. Here is some filename length limit in popular file sy

  • MS Windows issue - "Filename or extension is too long"May 30

    I run Microsoft windows on a few of my machines. I don't know if many people know about this issue in the OS but you can't have very long filenames, from what I know Linux can have longer names, I have never run into this issue on my Linux machines.

  • Stopping too long filenames in Windows Server 2003June 9

    We're finding a problem with long filenames, usually on "My Documents" or on shared drives. Basically, it seems that a document could be written that has a very long filename, and saved say in "My Documents". Which is fine on that comp

  • Rename files to empty filename in Windows (Vista)June 9

    Vista allows files with empty "first name" (for example, ".svn"). However, when I try to remove the filename of an existing file, leaving the prefix, in Explorer or using cmd's 'rename', I fail. How can I easily rename files to include

  • Remove all files by filename (Linux one-liner)June 10

    CakePHP has a convention of putting files called "empty" in empty directories. I'm sure they have a reason, but it really bugs me. (Yeah, OCD, I know...) I want a one-line linux shell command that will delete every file with the name "empty

  • SCP filename tab completionJune 16

    I use SCP regularly to move files between servers and I've heard rumoured that you can use tab-completion on the remote server if you're using public keys, but so far I have had no luck. What I'm trying to accomplish is the following: scp -r remote.i

  • Linux support for unicode filenamesJune 17

    I have a couple Linux fileserver running Samba, what do I need to do to support filenames with unicode characters? Do particular filesystem have better support for Unicode? Would I get better support by using something other then ext3? What do I have

  • correct format for datetime appended to filenameJune 25

    I'm trying to setup a batch file to execute a set of stored procs and dump the output to a timestamped text file. I'm having problems finding the correct format for the timestamp. Here is what I'm using osql.exe -S <server> -E -Q "EXEC <stor

  • Common Backup filenameJuly 20

    I was wondering when you guys have to backup a database or any directory in a server, what would be a good name to call them. For instance, database-2009-07-20.sql or directory_07_20_09.tar.gz Is there any standard for this? --------------Solutions--

  • Hebrew filenames in the URLJuly 21

    We have a CMS that enables users to upload images and flashes to their site. Sometimes the filenames are in Hebrew. In our development server there is no problem, but in our production server we get a 404 error when the filename ends with Hebrew char

  • Copy filename to clipboard

    Copy filename to clipboardJuly 29

    Is there a way to copy the currently selected filename, including the path, to the clipboard? Ideally this would be through the right-click menu. Some degree of flexibility would be useful, like the ability to copy just the filename, path+filename, f

  • Tool/method to reformat filenames

    Tool/method to reformat filenames July 30

    I've got a bunch of files named with a the pattern 99 - DescriptiveName.txt and I'd like to remove the number from the front so I just have DescriptiveName.txt. How can I do this? Can I do it from the command line or is there a utility that can do th

  • How do I show filenames only after a keyword grep search?August 21

    I currently have n data files in a directory where each file has at most 1 line of very long data. My directory structure is director/ data1.json data2.json data3.json I know that at least one of those files contain the keyword I'm looking for, but s

  • Ecryptfs Recovery but filename issuesAugust 24

    I'm trying to restore an encrypted home directory from an external drive (taken from a broken machine). I've done it before, but this time I can't get it to un-encrypt the filenames! Any help on where I'm going wrong would be much appreciated... Reco

  • Insert FileName into MS Word footerSeptember 8

    The company I work for requires that every document we provide has a footer. Currently we add the base footer: ABC Inc/{FileName}/{CreatedDate}/ to the Normal.dotm for everyone and they have to manually change their document's footer with the correct

  • DVD authoring software that makes menus automatically (using filenames in menus)?September 11

    I often grab handfuls of .mpg or .avi movies and burn them to playable DVDs. I like having DVD menus, but I don't really need them to say anything beyond what's in the filename. Right now I'm using DeVeDe, but I'm growing tired of creating and editin

  • Filename filter for windows explorer

    Filename filter for windows explorer September 14

    I'm not looking for a windows explorer alternative. I like it, and it does its job well. However, the one thing I'm missing from it, is the function to filter the filenames by a specified criteria. For example, *visual*.pdf would show me all files wh

  • Linux - Command line tool to normalize a filename?September 15

    Is there a command line tool in linux that will 'normalize' a filename? i.e. remove all "xx/./xx" parts, or "myfolder/../myotherfolder" parts? --------------Solutions------------- Actually, it is realpath: http://linux.about.com/librar

Copyright (C) 2018 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.434 s.