Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i would like to be able to enclose this variable command var1=$(ls *.html) with quotes.
for instance, if there are files in the directory like:
hello world.html and hello.html
when i pass the ls *.html to the command line, i want it to return quoted
so when i call the variable var1
echo $var1
"hello world.html" "hello.html:
and not
hello world.html hello.html
one way of doing it is using sed but is there another way.
ls | sed -e 's/^/"/' -e 's/$/"/g'
Hey, I've been using Linux for 6-7 years and only noticed that option last month. In some cases, you may need to make sure it's using the /bin/ls and not the shell built-in ls (only some shells have a built in, but most of those don't support the -q options).
cool, so im trying to do this in order to move files but when i try this command to move the files, it returns and error
files in the directory are
h m.html
q d.html
#!/bin/bash
for file in `ls --quote-style=shell *.html`
do mv $file /temp
done
> ./m.sh
"h
mv: cannot stat `"h': No such file or directory
w.html"
mv: cannot stat `w.html"': No such file or directory
"q
mv: cannot stat `"q': No such file or directory
d.html"
mv: cannot stat `d.html"': No such file or directory
why the errors?
i have tried adjusting the ls command but no luck
Yes that worked, thank you
but it is there an explanation why the other command didn't work. i would sure love to be able to use the ls command
the reason being that I am tying to save the files as a variable so i can call them to do different things before the move command
converting them to ps
printing them and then moving to a different directory
find . -name '*.html' -exec mv {} /temp \;
Interesting, I can seem to get to use the "for" script
i even went to the basics and tried it line by line
files in directory:
index 1.html index 2.html
var1=$(ls -Q *.html)
mv $var1 /temp
cp $var1 /temp
neither command work s
but if i actually write
mv "index 1.html" "index 2.html" /temp
it works just fine
What do you think?
Did the "for script work for you?
The for script works fine for me. Please place an "echo" before the mv in the script so we can see what commands it wants to execute and then post the output here.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.