Go to directory or creat it and go to

[[ -d dir ]] || mkdir dir ; cd dir
For use in scripts this command is very usefull

1
By: voyeg3r
2009-03-12 17:19:13

These Might Interest You

  • This command uses the debugger to attach to a running process, and reassign a filehandle to a file. The two commands executed in gdb are p close(1) which closes STDOUT and p creat("/tmp/filename",0600) which creates a file and opens it for output. Since file handles are assigned sequentially, this command opens the file in place of STDOUT and once the process continues, new output to STDOUT will instead be written to our capture file. Show Sample Output


    7
    yes 'Y'|gdb -ex 'p close(1)' -ex 'p creat("/tmp/output.txt",0600)' -ex 'q' -p pid
    adminzim · 2009-02-20 17:36:57 4

  • 0
    fsutil hardlink creat new_file exits_file
    hpyhacking · 2011-05-26 16:28:48 0

  • 0
    useradd -s /sbin/nologin nicdev
    nicdev · 2009-02-15 14:49:17 0
  • Use tar command for a backup info with a date of creation Show Sample Output


    1
    tar --create --file /path/$HOSTNAME-my_name_file-$(date -I).tar.gz --atime-preserve -p -P --same-owner -z /path/
    Odin_sv · 2009-09-07 04:52:12 1

What Others Think

actually mkdir -p is much better approach
shabunc · 484 weeks and 3 days ago
@shabunc: mkdir -p do not change to the created directory.
roebek · 484 weeks and 2 days ago
@roebek: mkdir -p smthng && cd smthng )))
shabunc · 484 weeks and 2 days ago

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: