All Questions
64
questions
2
votes
1
answer
3k
views
Copy array of multiple files with globbed extensions, in bash 3.2
I've found bits and pieces of each of the things I want to do across the Web, but nothing exactly fits my use case.
I'm trying to write a script that copies multiple specific files to a directory on ...
2
votes
3
answers
350
views
grep .* returns results from .bash_history and complains about
I'm new to Linux and so far I've been playing around with some utilities, specifically the grep utility. I decided to create a new file (aptly called 'newfile') with the following content:
Lady of ...
10
votes
1
answer
11k
views
Bash substitution with variable defined from a glob pattern
The below example explains the issue. Why is the FILENAME printed correctly when echoed and perceived as a pattern when using substitution?
#!/bin/bash
FILEPATH_WITH_GLOB="/home/user/file_*"
...
2
votes
2
answers
7k
views
tar exclude files *.zip
Why don't *.zip patterns work in tar :
tar cfjv backup.tar.bz2 --exclude mydir/files/*.zip mydir
Is there another syntax?
5
votes
2
answers
6k
views
scp command behaves differently when used with expect utility
expect -c 'spawn scp -C -o CompressionLevel=9 ~/partFiles/* [email protected]:/export/home/abc/; sleep 10; expect password; send "secretPassword\n";interact'
throws - ~/partFiles/*: No such file or ...
1
vote
1
answer
118
views
how to locate a name-not-specified file in bash? [closed]
I have a bash like this to easily upload a file to my server:
FILE=../"$1"/1.txt
scp 1.txt remoteserver #upload the file to a remote server.
The $1 is for input directory and I have a lot of ...
4
votes
4
answers
12k
views
Passing wildcard * to a (bash?) script [duplicate]
I want to to remove all color codes which look like '@n', '@R' etc, from a moderately large size collection of text files.
So in a file called 'remove_cc', I wrote the following:
sed -ie 's/@r//g' $...
30
votes
5
answers
59k
views
Bash script error with strings with paths that have spaces and wildcards
I am having trouble getting the basics of Bash scripting down. Here's what I have so far:
#!/bin/bash
FILES="/home/john/my directory/*.txt"
for f in "${FILES}"
do
echo "${f}"
done
All I want to ...
2
votes
2
answers
8k
views
Problems with basename in a loop
I am new at shell script programming and I'm trying to execute a software that reads a text and perform it's POS tagging. It requires an input and an output, as can be seen in the execute example:
$ ...
9
votes
3
answers
6k
views
ImageMagick on multiple files
I have converted a single file from BMP to PNG with ImageMagick's convert using the command below
convert CD\ Front.bmp CD\ Front.png
I have many such files, thus I tried:
for f in */*.bmp ; do ...
2
votes
1
answer
180
views
Why does copying from a script screw with my files?
I am at a loss here, trying to find out the reason why a shell script that is basically copying a couple of files and directories from one place to another will result in the content of two of the ...
25
votes
2
answers
19k
views
Delete all files starting with a question mark
I have a folder in which I have around 4k files. Some of these files start with a a ? or ! character. I need to delete them but can't find an expression that would do so:
rm -f ./?*
just deletes ...
10
votes
2
answers
1k
views
What is the difference between "*.pl" and *.pl in grep? Why does quoting change the result?
What is the difference between:
grep "string" . -r --include *.pl
and
grep "string" . -r --include "*.pl"
The latter includes files in subdirectoried while the former not. Why?
2
votes
3
answers
4k
views
Very strange behavior with grep and IFS
I'm having trouble using grep, the returned results are "n-empty", I mean without the 'n' character...
This is the script sample :
OLDIFS=$IFS
IFS="\\n"
i=$(grep -ril $1 *)
echo $i
IFS=$OLDIFS
I ...
56
votes
1
answer
33k
views
Wildcards inside quotes
This will be an easy one, but in my memories, when shell scripting, using double quotes would allow expanding globbing and variables.
But in the following code:
#!/bin/sh
echo *.sh
echo "*.sh"
echo ...