Howto create a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Howto create a file
# 1  
Old 02-07-2007
Howto create a file

Hi folks,

How do we create a file using shell script?
i mean to say that do we use
is it a good approch to do
echo "abc" >file
echo "xxxx" >>file

or is there any better method?

Thanks,
Amit
# 2  
Old 02-07-2007
try this

Code:
cat > 111

After this type text and press ^d to save a file.
# 3  
Old 02-07-2007
Both approaches are correct what really matter is your choice.
you can create file using ">" operator and later you can append on same file with ">>" operator.
# 4  
Old 02-07-2007
why not using touch?
ex. touch filename

cu
lowbyte
# 5  
Old 02-07-2007
Thanks to all of you,this almost satisfies my querry.
# 6  
Old 02-07-2007
If you need a file with a certain size, use dd command or check the man pages depending on your needs.
The last thing I needed was to create 150GB file, I did it like that :
Code:
dd if=/dev/zero of=150g bs=1073741824 count=150

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Howto remove extra space in the file

Hi Gurus, I have a file which contains some special char or space. when using cat -evt I can see the file as following: 0,"0000","abc/def aaa ... (6 Replies)
Discussion started by: ken6503
6 Replies

2. Shell Programming and Scripting

Howto add a constant column to the text file

Hi, I am converting a .DBF file to pipe delimited file my requirement is like lets say my .DBF is residing in path /a/b/c/d/f/abc.DBF I need my .txt file as having a column with source _cd =f sample data in .DBF in folder "f" c1 c2 c3 1 2 3 in txt file it should be... (4 Replies)
Discussion started by: angel12345
4 Replies

3. Red Hat

HOWTO transfer Hosts in excel sheet to file in LINUX?

Hi guys! I have around 300 hostsname is excelsheet in one column. These hosts I want to add in one file in linux one after the another like hostname1,hostname2.hostname3, I don't want to waste enter it manually it very time consuming, so how to transfer these files from excelsheet to a... (1 Reply)
Discussion started by: manalisharmabe
1 Replies

4. Shell Programming and Scripting

howto change format of file?

Hi I have a file with this inside: How can I change it to: thanks a lot regards Israel. (3 Replies)
Discussion started by: iga3725
3 Replies

5. AIX

howto extract a file from a bff file?

Hi howto extract a file from a bff file? Is it possible? thanks Israel. (1 Reply)
Discussion started by: iga3725
1 Replies

6. Shell Programming and Scripting

HOWTO create in UNIX a Microsoft Excel-Sheet (with data from Oracle)

Hi HOWTO create in UNIX a Microsoft Excel sheet (with data from Oracle). At the moment I am making CSV files (using SQL statemens with || ';'), but search for more advanced formatting. Don't wish to use Perl. cheers (4 Replies)
Discussion started by: slashdotweenie
4 Replies

7. Shell Programming and Scripting

Howto process log file from where it left

Hi all I am doing some matching apache access log processing.Now i want a some way that i can start log search/process from where it left.Can any one give me ideads. (1 Reply)
Discussion started by: aliahsan81
1 Replies

8. Solaris

Howto create new service bundle

Hi, I have created a service referring the below link. https://www.unix.com/tips-tutorials/32987-creating-solaris10-service.html Now am able to import and enable the service. I have placed my xml file under /var/svc/manifest/site The service name is <service ... (3 Replies)
Discussion started by: kalpeer
3 Replies

9. UNIX for Dummies Questions & Answers

Howto Attach File with Sendmail

Hi, How can I attach a file using sendmail? I tried /A option like this: $ /usr/bin/sendmail toaddress@gmail.com /A afile.txt but doesn't seem to work. - Monkfan (2 Replies)
Discussion started by: monkfan
2 Replies

10. UNIX for Dummies Questions & Answers

howto change parameter in vi to take tmp file

i have a problem running vi. there is no space in /var where it creates tmp file. How can I change this parameter so that it takes from other directory. thanks (4 Replies)
Discussion started by: ajaya
4 Replies
Login or Register to Ask a Question