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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
They are random files that are to be created in my home directory with those file names in which they are supposed to be irrelevant. I have used the touch command to create the files. A. touch untitled file B. touch **'s and ||'s C. touch >> README!! <<. The touch command works on files A and B. The third file gives me the error: touch >> READMEls <<
-bash: syntax error near unexpected token `newline'
You probably are using characters that have special meanings to the bash shell.
For example a * is a wild card that bash will expand before the touch command sees it's own arguments.
The > and < characters are used for redirection.
You need to escape these characters, or include them in quotes. Single quotes are better because some characters like `$' still have a special meaning inside double quotes. If a filename starts with a dash, the shell will think that the filename is an argument. You need to use -- between your command options and the filename argument.
Better yet, don't create files with spaces or special characters in them. It makes handling them in the terminal difficult.
I would suggest downloading the Advanced Bash Scripting guide from the www.tldp.org website. The first chapter covers the usage of each special character.
Does your README file include the >> <<? if you type that into the terminal by itself, it says '-bash: syntax error near unexpected token `newline', Whereas letters that aren't linked just says 'no command found'. I'm not that great with this stuff, but I think the terminal recognizes symbols(-,/,#,etc.) as command to seperate or re-direct and stuff like that, Try just calling the file READMES.
If I'm wrong please let me know, This is just a guess and I would like to know how it goes ... a little knowledge goes a long way. Best of luck.
jschiwal, guess we we're typing same time lol. So my assumption of symbols being command related was right? sweeeeeeeeeet I love learning!
Last edited by Hevithan; 04-22-2011 at 05:40 PM.
Reason: to include jschiwal's post
Hevithan: I've had some commands fail that worked on a large number of file arguments, or in a loop. I quoted the variable filename argument, but the problem turns out to be either a filename starting with a dash, or a filename containing `!'. The latter is especially nasty and hard to escape. The ! is used for bash history in an interactive bash session, but not when running scripts.
A dash only causes a problem if it is the first character. An underscore as the first character usually doesn't cause a problem but looks strange. Local functions sometimes use an underscore to prevent name collision with global functions or commands. For example, you may source a script with a _ls() function.
Imagine a file named "-picture.jpg". showfoto -picture.jpg will be interpreted as "showfoto -p -i -c -t -u -r -e .jpg"
The filename might be in a variable, so "showfoto $pic" would fail if $pic is `-picture'. Your script might work for a long time, then fail because of the filename. So you need to use "showfoto -- $pic" instead to prevent this from happening if possible.
When working interactively, one method of handling strange file names is to use auto completion. Type the first few letters and hit the TAB key. The shell will complete the word, escaping characters as needed. This can be useful for handling a file that has a different encoding or foreign characters you can't type.