LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 02-16-2011, 09:19 AM   #1
AiresTheBold
LQ Newbie
 
Registered: Feb 2011
Posts: 1

Rep: Reputation: 0
Shell Scripting text file creation issue


Hi all.

I'm just starting out with shell-scripting, but having a problem with making new text files with the touch or cat > commands.

What I've been doing is

touch testfile1.txt

Also, I've tried

cat > testfile1.txt
(text)


Regardless, console reports "bash: text1.txt: No such file or directory.
Consfusingly, it works fine in the home-directory. But if I move the file to where I want it, I can no longer view, edit, etc. it.

What am I doing wrong?
 
Old 02-16-2011, 09:27 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Well, you can create the file exactly where you want it specifying the full path, e.g.
Code:
touch /path/to/some/dir/testfile1.txt
but you need writing permissions for the destination directory. If it is in your HOME or in /tmp you have no problem, otherwise you should acquire root's privileges to write into system directories or into other users' HOME.
 
  


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
writing data or text to a file using shell scripting vinaytp Linux - Newbie 3 04-24-2009 12:16 AM
shell scripting: "formatting" issue with text files eur0dad Programming 3 08-17-2006 10:50 AM
how to change some text of a certain line of a text file with bash and *nix scripting alred Programming 6 07-10-2006 11:55 AM
Reading text from a file using shell scripting. mrobertson Programming 11 06-29-2005 12:12 PM
Shell Scripting: using <printf> to align text need HELP!!! naomi Programming 2 01-06-2005 01:06 PM

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

All times are GMT -5. The time now is 12:39 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