create file

FILE=$(tempfile 2>/dev/null || echo .$RANDOM)
enter our information on the content file.
Sample Output
empty

0
By: s123iva
2011-08-31 10:39:11

These Might Interest You

  • Another way to create temp files in your scripts, if tempfile fails, it will create a hidden local file in the current directory, don't forget to delete $FILE


    0
    FILE=$(tempfile 2>/dev/null || echo .$RANDOM)
    h3nr1x · 2011-06-22 15:12:21 0
  • create iso image from directory . Usefull for virtualised machine To create CD ISO image of directories that contain long file name or non-8.3 format (particularly if you want to burn the CD image for use in Windows system), use the -J option switch that generates Joliet directory records in addition to regular iso9660 file names. For example, to create CD image of Vista SP1 directory: mkisofs -o VitaSP1.iso -J VistaSP1 Show Sample Output


    7
    mkisofs -o XYZ.iso XYZ/
    eastwind · 2009-10-17 16:28:47 0
  • Sometimes you have a script that needs and inputfile for execution. If you don't want to create one because it may contain only one line you can use the ` mysql -uuser -ppass dbname < <(echo "SELECT * FROM database;") This can be very usefull when working with mysql as I showed in the example code above. This will create a temporary file that is used to execute mysql and for example select all entrys from a specific database.


    9
    any_script.sh < <(some command)
    cb0 · 2010-02-21 18:44:33 13
  • Command to create a dummy file (full of nulls). Useful for testing e.g. file transfers when no file is at hand. bs = blocksize, count = filesize in kilobytes


    -2
    dd if=/dev/zero of=filename.file bs=1024 count=10240
    harpo · 2012-01-19 08:38:14 5

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: