Tagged Questions
1
vote
1answer
75 views
How to prevent double escaping?
I'm trying to put a bunch of images together into a pdf. I ran gm convert *.jpg out.pdf and it worked, but the images were not in the right order.
I found that ls -v orders them correctly so then I ...
7
votes
1answer
134 views
What is the significance of the dot in bash commands and how is it different from an asterisk?
I'm trying to understand the significance of the dot in bash and how it differs from an asterisk. Can someone please elaborate? For example, what's the difference between cp -ar /foo/. /foo2/ and cp ...
2
votes
3answers
195 views
Manipulate file name piped from find command
I'm relatively new to Bash and am trying to do something that on the surface seemed pretty straightforward - run find over a directory hierarchy to get all of the *.wma files, pipe that output to a ...
0
votes
1answer
64 views
Create a File with Touch on a specific Directory
I want a create a file with a specific extension(.done). I am using the command touch. Something Like:
touch `basename $UNZIPFILE`".done"
It's creating the file but in current directory. I want to ...
0
votes
1answer
61 views
Find and use the path of a file?
I'm trying to find the path of a file and move it.
When I try realpath, it is not useful.
For example : I want to move the file All Hail the Generalist - Vikram Mansharamani - Harvard Business ...
1
vote
2answers
216 views
Reserved characters in file names
I was under the impression that the only character not allowed in file names was /, but I don't seem to be able to create a file whose name contains characters such as *, \, ", :, |, < or > ...
19
votes
2answers
2k views
What does dash “-” at the end of a command mean?
Given the following command:
gzip -dc /cdrom/cdrom0/file.tar.gz | tar xvf –
What does the - at the end of the command mean? Is it some kind of placeholder?
2
votes
4answers
433 views
chown all files based on file name pattern in current directory
I'm trying to chown all files whose filenames begin with ChownFileNames. I've used this command, but it doesnt seem to work:
find . -maxdepth 1 |grep 'ChownFileNames*' -exec chown hadoop:hadoop -- {} ...
0
votes
2answers
111 views
How to copy a file and move it to a location using unix
I need a file to stay in the same location but also move it to a different location.
What am I doing wrong?
cp RubyTest.sublime-settings \
~/Library/Application Support/Sublime\ Text\ ...
7
votes
3answers
474 views
Change the color of the file name text
I am writing scripts to initialize and configure a large system with many components.
Each component has its own log file.
I would like to change the color of the component file name to red whenever ...
2
votes
3answers
304 views
Rename a lot of files with all types of characters, with POSIX portability
Sometimes I need to rename all the files (the renaming convention follows later) in a directory where the filename is always in the form of 'filenamename.extension' (extension always exists and ...
3
votes
3answers
785 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 ...
2
votes
3answers
91 views
Selecting latest files and grouping by name
I have a directory containing files of the following name structure.
<device>.<yyyy-mm-dd-hh-mm-ss>
I am working on a script that will retain the the last X copies of these ...
11
votes
4answers
3k views
Converting relative path to absolute path
Is there a *nix command to get absolute(and canonicalized) path from relative path(with current path) or symbolic link?
5
votes
1answer
632 views
Best way to remove file extension from a string?
So, I'm using a script I've made to convert videos to the webm format. A certain program calls the script, sending %f which is the full, absolute file name of the video, like this:
converter.sh %f
...
4
votes
3answers
1k views
How do I move some but not all files from one directory to another?
I need to move my files from one directory to other. But there is some issues. My file name pattern is like:
apple.0, apple.<n>, n -> {0,1,2,3 ...~ }
so mv apple.* will not work, because ...
7
votes
4answers
466 views
How can I find a file whose name includes a given string, such as “abcde”?
Within a set of directories, how do I find a file whose name includes a given string, such as "abcde"?
2
votes
1answer
498 views
shopt -s nocaseglob is not working on Ubuntu
Case insensitive file name globbing is not working in bash on Ubuntu 11.04 64bit. The shell options specified in .bashrc are as follows:
shopt -s nocaseglob
shopt -s nocasematch
shopt also shows ...
3
votes
2answers
139 views
returning strings corresponding to shell glob matching
Suppose I have a subdirectory called sub. Then I want to operate on all files in that directory with the extension "txt". I want something like
for f in sub/*.txt
do
enscript -b "" -o {$f ...
12
votes
3answers
3k views
bulk rename (or correctly display) files with special characters
I have a bunch of directories and subdirectories that contain files with special characters, like this file:
robbie@phil:~$ ls test�sktest.txt
test?sktest.txt
Find reveals an escape sequence:
...
12
votes
6answers
7k views
Grabbing the extension in a file name
How do I get the file extension from bash? Here's what I tried:
filename=`basename $filepath`
fileext=${filename##*.}
By doing that I can get extension of bz2 from the path /dir/subdir/file.bz2, ...