LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-06-2017, 09:54 AM   #1
Hcardinal
LQ Newbie
 
Registered: Sep 2017
Posts: 2

Rep: Reputation: Disabled
Learning Special Characters


Hey guys, I need some help figuring out how to make bash not consider these special characters.
Here's the question:

Exercise 1: Review the following file names and identify the special characters. Once you’ve identified the special characters, re-write the file name with the proper escaping of special characters.
  1. ‘A super important file.’
  2. ‘Peanut-Butter & Jelly’
  3. ‘Linux > Windows’
  4. ‘Big ole sacks of $$$’
  5. ‘\ Filename with BackSlashes \’

For some reason this is super confusing to me, thanks in advance for the help!
 
Old 09-06-2017, 10:00 AM   #2
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 579

Rep: Reputation: 267Reputation: 267Reputation: 267
What is confusing?
Try breaking down your question into what specifically you are not understanding.

Escaping? special characters?
 
Old 09-06-2017, 10:02 AM   #3
Hcardinal
LQ Newbie
 
Registered: Sep 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Sefyir View Post
What is confusing?
Try breaking down your question into what specifically you are not understanding.

Escaping? special characters?
How to make BASH not see those as special characters.
For example, the first one, would it be \A\ \super\ \important\ \file\?

I don't quite understand where the \ goes to cancel out each "Special character".
 
Old 09-06-2017, 10:14 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 7,119
Blog Entries: 12

Rep: Reputation: 2627Reputation: 2627Reputation: 2627Reputation: 2627Reputation: 2627Reputation: 2627Reputation: 2627Reputation: 2627Reputation: 2627Reputation: 2627Reputation: 2627
Hi Hcardinal and welcome to LQ.

Please refer to our Welcome to LQ link for information about how to ask a more effective question.

Be aware that if this is an assignment, it is not a problem posting questions about it, however assignment or not, our guidance is that you should indicate what you have personally tried, or offered more details similar to what you've done with your first follow-up. Meanwhile an LQ Rule is to not post assignments verbatim, which you appear to have done.

You seem to be reading a lesson, be that for personal learning or as part of course. My experience is that prior to an exercise such as this, whatever the reading reference is, will inform you what special characters include. Therefore you should know if capital letters are considered special versus not. A: They are not.

Since this is regular expressions and special character delimiters. A simple suggestion is to go to a Linux system, find a place which has at least one .txt file that does not have to have any of these strings and then try them out using grep:
Code:
$ grep A super important file *.txt
What happens?

It complains about "super".
It complains about "important".
It complains about "file"

It does not complain about "A"

So try:
Code:
$ grep A\ super\ important\ file *.txt
And once again, it is irrelevant that any TXT files contain that string, however what you'll find is now the shell will not complain to you about your search string, because you have delimited it. Meanwhile if you do delimit the capital A it will not complain also. This only means that it does not care if you overdo it.
 
1 members found this post helpful.
Old 09-07-2017, 01:35 PM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 9,677
Blog Entries: 7

Rep: Reputation: 2393Reputation: 2393Reputation: 2393Reputation: 2393Reputation: 2393Reputation: 2393Reputation: 2393Reputation: 2393Reputation: 2393Reputation: 2393Reputation: 2393
Quote:
Originally Posted by Hcardinal View Post
I don't quite understand where the \ goes to cancel out each "Special character".
well then try.
do your homework yourself, don't copy it down from your neighbor.

you do have a bash shell to try things out, don't you?
 
Old 09-07-2017, 09:15 PM   #6
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,498

Rep: Reputation: 259Reputation: 259Reputation: 259
Shortcuts, will take you where you want to go easily.

But understanding the basics makes a solid ground.

Try this link: https://www.shellscript.sh/escape.html

Grab Linux installed it in a Virtual environment, and do the bash yourself.
 
Old 09-12-2017, 11:39 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170
This is a good homework exercise, and you really do need to work through it yourself.

These well-chosen examples are representative of things that you will encounter and that you will need to be able to do. There are no short-cuts. Don't shortchange yourself.

If you don't entirely understand the question, go to your instructor(!) for clarification. This is the only way that your instructor will become aware that there is confusion concerning the question. Don't leave him/her in the dark: classroom learning needs the very active participation of both instructor and student. (Spoken by someone who's been in the front of the room ...)

Last edited by sundialsvcs; 09-12-2017 at 11:42 AM.
 
1 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
[SOLVED] special characters help? bednarjm Fedora 8 06-18-2012 09:09 PM
Special Characters SimeonV SUSE / openSUSE 14 07-07-2006 01:29 PM
special characters greenbox Linux - Software 9 12-23-2005 07:33 PM
Special characters consty Programming 3 08-07-2005 05:53 AM
using special characters one_ro Mandriva 5 11-04-2004 08:52 AM

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

All times are GMT -5. The time now is 06:17 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration