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 03-26-2008, 11:00 AM   #1
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Rep: Reputation: 16
Smile creating a file


how many ways u can creat a file in linux.
as per my concern i can do in three ways
1.cat > file name
2.with the help of editor like vi , vim etc
3.with help of echo command as
echo "this is the content of my file" > filename

do u have any other idea on file creation.
 
Old 03-26-2008, 11:05 AM   #2
rabbit2345
Member
 
Registered: Apr 2007
Location: 中国上海
Distribution: openSUSE 11.3
Posts: 371

Rep: Reputation: 40
if you use KDE, then you can:

1. right click on the desktop

2. find the section that says "Create New"

3. Select the new file type

4. name it

there are so many ways to create new files, from downloading something, to saving documents, as mentioned earlier

good luck,
rabbit2345
 
Old 03-26-2008, 11:44 AM   #3
mahmoud
Member
 
Registered: Apr 2006
Location: UK
Distribution: Mandriva, Debain, Redhat, Fedora, Ubuntu, FreeBSD
Posts: 269

Rep: Reputation: 30
touch filename
 
Old 03-26-2008, 11:53 AM   #4
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 307

Rep: Reputation: 41
Depends

If you are trying to populate a file with information from another file or from the results of a command you can use the redirection operator
>>. Example (correct me if I'm wrong people)

dmesg >> myfile.txt (Send the output of the dmesg command to a file named myfile.txt)

cat myfile.txt >> myfileToo.txt (Send the content of the file myfile.txt to a new file myfileToo.txt)

Granted the file extentions aren't necessary, but old DOS habits die hard LOL.

Good Luck
Ace
 
Old 03-26-2008, 11:57 AM   #5
BashTin
Member
 
Registered: May 2003
Location: West Midlands, United Kingdom.
Distribution: Slackware 14.1
Posts: 261

Rep: Reputation: 32
Or at a lower level in C.....

Code:
file = fopen ("file.txt","w")
BashTin
 
Old 03-26-2008, 11:57 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
You could use this in a script as well:

: >file

The colon is a null command. It is the redirection that creates the file.
 
Old 03-26-2008, 12:03 PM   #7
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
You can use touch, passing it a not-yet-existing file name as an argument. You could use re-direction without anything to re-direct. You could also copy another empty file... /dev/null always exists and is empty, so that's a good candidate.
Code:
$ touch file
$ > file2
$ cp /dev/null file3
$ ls -l
total 0
-rw-r--r-- 1 matthew matthew 0 2008-03-26 16:02 file
-rw-r--r-- 1 matthew matthew 0 2008-03-26 16:03 file2
-rw-r--r-- 1 matthew matthew 0 2008-03-26 16:03 file3

Last edited by matthewg42; 03-26-2008 at 12:05 PM.
 
Old 03-26-2008, 09:47 PM   #8
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Original Poster
Rep: Reputation: 16
it's great that i have got the other 3 way creating empty file.

thank u...
 
Old 03-26-2008, 11:12 PM   #9
prad77
Member
 
Registered: Mar 2008
Posts: 101

Rep: Reputation: 15
$ dd if=/dev/zero of=test.bin bs=1000000000 count=1

will generate a 1G file .

Gentoo

Last edited by prad77; 04-17-2008 at 04:28 AM.
 
  


Reply

Tags
file


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
Copy File While File is Creating in Disk suhas7860 Linux - General 4 04-03-2007 09:38 AM
creating file sahel Programming 1 01-09-2006 06:22 AM
when creating a *.iso file, how to make the file size smaller? minm Linux - Newbie 8 12-26-2004 10:58 PM
Creating a File Melissa22 Linux - Newbie 3 02-18-2004 02:48 PM
Creating new file link1305 Linux - Newbie 5 11-26-2003 09:59 PM


All times are GMT -5. The time now is 04:04 PM.

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