LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 07-03-2020, 09:33 AM   #16
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,744

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381

Worth mentioning that files containing embedded " cannot just be just enclosed in double-quotes.

If choose copy in my GUI file manager (nemo), then in a CLI style interface (gnome-terminal) a right click will offer an option to "paste as filenames" - which will paste my selection(s) as fully qualified filenames, enclosed in single quotes. It will also replace any embedded single quotes with '\''; presumably any other bad characters will also be handled appropriately?

I know this is a bit idle, mixing up GUI and CLI - but some video files are extremely long, with multiple spaces and its very quick to do.
 
Old 07-03-2020, 10:17 AM   #17
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 1,140

Rep: Reputation: Disabled
There's a Perl module String::ShellQuote which provides a command-line tool shell-quote that could be used in scripts to safely quote arbitrary strings.

The recent versions of Bash have ${parameter@Q} expansion.

The GNU coreutils printf(1) command and the Bash builtin of the same name have a %q format specifier.
 
Old 07-03-2020, 11:18 AM   #18
Meow1234
LQ Newbie
 
Registered: Jul 2020
Distribution: several
Posts: 28

Rep: Reputation: Disabled
Use this command. mv “file” “destination” with quotes.
 
Old 07-05-2020, 06:54 PM   #19
Pen guin
Member
 
Registered: Oct 2019
Posts: 125

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Meow1234 View Post
Use this command. mv “file” “destination” with quotes.

Let me put it this way...

You are a post man, and you are on the ground floor, or G. You have a letter to deliver to the first floor. Not just anywhere on the first floor but office 123, then to tenants office, so he can receive his mail. The office (123) represents the Folder, and the tenants office represents the subdirectory.

Would that same syntax still apply?

That's exactly what I'd like to do, in Bash, if that makes sense. If I could do that all in one swing, that would be great.
 
Old 07-06-2020, 01:47 AM   #20
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 1,140

Rep: Reputation: Disabled
I still don't see what's your problem.
Code:
mv post floor_G/office_123/tenant_X/
 
Old 07-06-2020, 02:07 AM   #21
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,825

Rep: Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874
the general rule is to use quotation with variables everywhere. The only exception is when you really know why not.
so use: mv "$SOURCE" "$DEST"
in bash space is a delimiter, so if you want your string to be kept in one you need to use quotation for that string too.
so use: mv "this dir" "that dir"
Other solutions were also posted (like post #17).
 
Old 07-06-2020, 06:03 AM   #22
Pen guin
Member
 
Registered: Oct 2019
Posts: 125

Original Poster
Rep: Reputation: Disabled
Pan64,

Without going back thru the entire thread, other members probably did post a solution to the question I asked. But shruggy's reply gives me the syntax that bash is looking for in the example he provided. I'm not saying there aren't others, that provided an example,like his, his is just the that resonated with me; that I understood.

shruggy, thanks for your post, and my motivation in all of this is to become proficient in using bash. And, once you do know your way around it, it will become faster than using the GUI. And I actually get to learn something new, which I enjoy.
 
Old 07-06-2020, 06:32 AM   #23
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 14,946
Blog Entries: 9

Rep: Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230
Please mark your thread SOLVED now.
See my signature for how to do that.
 
Old 07-06-2020, 07:41 AM   #24
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,825

Rep: Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874Reputation: 4874
Quote:
Originally Posted by Pen guin View Post
And I actually get to learn something new, which I enjoy.
This is the point.
 
Old 07-12-2020, 04:31 PM   #25
Hermani
Member
 
Registered: Apr 2018
Location: Delden, NL
Distribution: Ubuntu
Posts: 184
Blog Entries: 1

Rep: Reputation: 74
For this kind of jobs I can recommend using Midnight Commander (mc). It is a "Norton Commander" (1) lookalike and it works very nice. It is used in the CLI.

To my knowledge it is found in every repo so, for example in Ubuntu, just use the following commands to install and use it.

Code:
user@desktop:~$ sudo apt install mc

user@desktop:~$ mc
If you need to do things that require root level access, you just use mc with the sudo command:

Code:
user@desktop:~$ sudo mc
Attached a screenshot of Midnight Commander, so you can see how it looks. There are two panes and you can easily copy or move files and directories around using the function keys. If you work in a terminal windows, you can even use the mouse

(1) Norton Commander was a piece of software first published in 1986 (about 34 years ago): https://en.wikipedia.org/wiki/Norton_Commander. It has been around in one form or another for all those years.
Attached Thumbnails
Click image for larger version

Name:	mc_screenshot.png
Views:	3
Size:	163.7 KB
ID:	33646  

Last edited by Hermani; 07-12-2020 at 04:49 PM.
 
Old 07-13-2020, 12:36 AM   #26
Hermani
Member
 
Registered: Apr 2018
Location: Delden, NL
Distribution: Ubuntu
Posts: 184
Blog Entries: 1

Rep: Reputation: 74
Quote:
Originally Posted by romared403 View Post
i think this is such a basic bca level stuff
?? This is a basic level forum so people with basic questions come here to get basic level answers, mister first-post.
 
2 members found this post helpful.
Old 07-16-2020, 03:44 AM   #27
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 14,946
Blog Entries: 9

Rep: Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230Reputation: 4230
Quote:
Originally Posted by romared403 View Post
i think this is such a basic grad level stuff Spam Spam Spam
Spammer reported.
 
3 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
From *inside* save dialogs: Ability to move files around, delete, move directories, etc.? Caja integration doesn't do it. tgm1024 Linux - Software 4 11-12-2019 01:36 PM
How to recursively merge directories or folders into one, retaining folder names in file names stozi Linux - General 6 05-22-2019 01:16 AM
[SOLVED] Burning with cdw: file names are too long, try "Long Joliet file names" lucmove Linux - Software 3 02-21-2017 06:06 AM
long long long: Too long for GCC Kenny_Strawn Programming 5 09-18-2010 01:14 AM
Little bash script and file to give long (or any) directories short names WardXmodem Programming 1 11-23-2009 12:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration