Can I create a file from the command line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can I create a file from the command line
# 1  
Old 10-20-2008
Can I create a file from the command line

I want to create a file explicitly from the command line without going in to the file directly just create it. Can I do that? Thanks in advance.
# 2  
Old 10-20-2008
man touch


hehehe, how often does a unix command open itself up to a perfect "that's what she said"
# 3  
Old 10-20-2008
nice thanks
# 4  
Old 10-21-2008
Or, without using an external command:
Code:
: >filename

(In any Bourne-style shell but zsh, simply ">filename" will work; zsh will insert a default command (whose default value is "cat").)
# 5  
Old 10-21-2008
Quote:
Originally Posted by geekosaur
(In any Bourne-style shell but zsh, simply ">filename" will work; zsh will insert a default command (whose default value is "cat").)
Please check the manual.
# 6  
Old 10-21-2008
You mean this one ("REDIRECTIONS WITH NO COMMAND" in zshmisc(1))?

Otherwise, if the parameter NULLCMD is set, its value will be used as a
command with the given redirections. If both NULLCMD and READNULLCMD
are set, then the value of the latter will be used instead of that of
the former when the redirection is an input. The default for NULLCMD
is `cat' and for READNULLCMD is `more'.

If and only if zsh is run with the name sh or ksh, NULLCMD is set to ':' for compatibility.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Create new folder and text file the same time in one line

Is it possible to create new folder and write a new text file in the folder while the current position is outside the new folder? in one line mkdir folder | echo "hello test"> folder/test.txt not work. (1 Reply)
Discussion started by: cmdcmd
1 Replies

2. Shell Programming and Scripting

How to create a file contains millions of lines and each line has different datas?

I want to create a file contains millions of lines. The line format like this: acnum$$123456$$+$$Tom$$111$$ fields separated by $$, field 1 and field 3 have only two options:acnum or crenum; + or -. field 4 can be any name or any letters. Other fields can be any fixed length digits. So, I want to... (9 Replies)
Discussion started by: hhdzhu
9 Replies

3. Shell Programming and Scripting

Need one line command to create and set password for new user...

Using useradd abc --password password (5 Replies)
Discussion started by: Jagruti Rml
5 Replies

4. UNIX Desktop Questions & Answers

Create/remove desktop short cuts via command line RHEL 6.3....

I would like to write a script that would remove and/or create shortcuts in Gnome desktop in RHEL 6.3... I googled all over the place could never find what I needed... Any help would be greatly appreciated! Thank you! (0 Replies)
Discussion started by: ruberked
0 Replies

5. Shell Programming and Scripting

create txt file form data file and add some line on it

Hi Guys, I have file A.txt File A Data AK1521 AK2536 AK3164 I want create text file of all data above and write some data on each file. want Output on below folder /home/kka/out AK1521.txt Hi Welocme (3 Replies)
Discussion started by: asavaliya
3 Replies

6. Shell Programming and Scripting

Create list in command line

How do you create lists or arrays in the command line? And how do you access specific cells of the list? (1 Reply)
Discussion started by: locoroco
1 Replies

7. Shell Programming and Scripting

Delete one Line from Main File and Create another

Hi I need to write a script which will search for some text in some CSV files and will delete the record/line with the matching text and will insert that record/line into some other file. Can you please help? Here is what I want: - Contents of MainFile.csv: - 1,2,3,Loan,4,5,6... (3 Replies)
Discussion started by: kapilk
3 Replies

8. Shell Programming and Scripting

How do I create an array from a file using every 3rd line

A file contains the following information shown below. Every ceName has 2 consecutive lines that have to be evaluated, using awk, sed, cut (any common unix tools). Input file: ceName: Node-1 processName: tzMgmt Status: PROCESS_NOT_RUNNING ceName: Node-2 processName: tzMgmt Status:... (15 Replies)
Discussion started by: BRH
15 Replies

9. Shell Programming and Scripting

read line by line and create new file

I would like to read line by line out of a file (one word per line) and create with each line a file. The read line should be also pasted into the file with some other text. Something like this: cat readfile.txt | mkfile readline << "bla bli $readline blu" (7 Replies)
Discussion started by: borobudur
7 Replies

10. UNIX for Advanced & Expert Users

create email w/ ASCII attachment via command-line

All, I need to email an ASCII data file to a business partner, and intended on creating a Korn Shell script to create an email message (minimal text), and attach the ASCII data file to the email. It seems this is not as easy as I had thought it might be. sendmail does not support... (3 Replies)
Discussion started by: jwperry
3 Replies
Login or Register to Ask a Question