General :: Command Line - Create Directories That Don't Exist While Creating A New File?
May 8, 2010
I can do:mkdir messages and then: touch messages/hello.txt Is there a command that will do both - create the directory if it doesn't exist, and then the empty file? Something like: touch -p messages/hello.txt
How can I create multipart rar file in Linux using the official console rar client?RAR 3.90 Copyright (c) 1993-2009 Alexander Roshal 16 Aug 2009Shareware version Type RAR -? for helpI want a multipart rar with each part size being 150 MB.
I am combining data from a couple different input files and creating an output file in a specific format. I notice that if I use the >> operator, information gets appended to a new line in my output file. This is useful, but if I'd like to append onto the CURRENT line, is there an easy way to do this? I've been googling around and see lots of complicated answers, nothing that suggests to me an easy way to do this. For example, if my output file looks like this:
b1a:] cat test hello my name is b1a:]
and I'd simply like to append "Bob", how can I do it? If I use
b1a:] echo Bob >> test b1a:] cat test b1a:] hello my name is Bob b1a:]
So what I would prefer is some command that would create the result:
I am trying to write a script to pick the directory name from a list of file. Here is a detailed picture.Have a file name LIST which contains the follwing for example/apps/oracle/product/test1/apps/oracle/product/test2/apps/oracle/product/test3I need a script that reads these line from LIST and creates foldersin /apps/oracle/product/test1/backup/date/test1 after reading the first line /backup/date/test2 after readin the second line/backup/date/test3 and so on.
which does not work on the invisible directories (why?). When I used ".*" as wildcard it changed all (visible) files including the parent directory (the one I was currently working in which is the "dot") . I can change the invisible directories owner and group using dophin but how is it done from the command line?
So I want to run command through ssh but also run a if check in bash to see ifa file exist. I know that to run ssh commands you do ssh user@server YOURCOMMANDbut if i need to run an if statements, how would this work??
i am in need of linux help. iam at college and i need this back/restore script to pass this final part of an assessment. i require a backup script that will not only backup but also restore files to the relevent directories. e.g. users are instructed to store all wordprocessor files in a directory named wp. so i am needing to create a backup directory and 3 directories within that and some files within the 3 directories and then back them up ot restore them. l know i should/have to do this myself by been trying to get/understand info for the last few days and came up with zero.
I want to make a webserver with multiple users allowed to login through SFTP to a specific folder, www.Multiple users are added, lets say user1 and user2, and all of them belonging to the www-data group. The www directory has an owner www-data and a group www-data.
I have used chmod -R 775 on the www folder, but after I try to create a folder test through my SFTP server (using Filezilla) the group of the directory created has only r and x permissions, and I am not able to log in with the second user user2 and create a directory within www/test due to a lack of w permission to the group.
I also tried using chmod 2775 on www directory, but without luck. Can somebody explain to me, how can I make it so that a newly created directory inherits the root directory group permissions?
I use putty to get to my RHEL 5.3 workstation from my Windows laptop.
Typically, if I want a new terminal on my windows 7 workstation from another terminal or mc, I have to type start and I will see a new terminal window running the default shell.
QUESTION : What is the equivalent command in RHEL 5.3 (and or solaris) to create a new terminal window from the command line ? I will be entering this command from the shell prompt or mc's command line.
In Windows, if I want to start another terminal and in that terminal, I want to run a program, I can do "start program.exe arg1 arg2". this will create a new terminal window and runs program.exe in that terminal window. I don't have to create a terminal and then in a separate step run the program. How can I do this in Linux ?
I want to create a logon script (or somesuch) that creates a file (if it doesn't already exist) and checks the file for some info otherwise. If it finds a given trigger in that file, it logs into a local database and does some operations.
Now my problem isn't with creating that file or even getting it to function as a logon script -- it's with permissions. After the logon script creates the file, I want that user to have read access on it ONLY. Further, I don't want to give the user any kind of root access so that they could do the database operations in question or chown/chmod the file.
What's the best practice here? I'm noticing that whenever the script runs (in .bashrc right now) the script runs with the current user's permissions. Ideally, I'd like to make it so the login script can run at a higher level of permissions, (higher than the user has). Is this even possible? What's the best way to do this?
I have one file called test.sh and in that file I have the below code. All this code is, is paths to three directories (as you can you can clearly see!).
Code: #!/bin/bash BACKUP="Documents /bin /sbin"
Now I have this other file which reads the directories (by using $BACKUP) and creates a tar file of everything in that folder. But what I am unsure of what to is create a bit of code that will simply look in test.sh, read all the directories and print a line saying either they all exist or some are missing. If possible it would be good to know which directories are missing too!
I have fiddled around with using -d but I can only get it to work for one directory or manually having to write out each directory.
I am currently interning at a place and my job is to essentially learn UNIX. My supervisor gives me problems here and there to help guide me with my learning but for the most part I'm doing this all by self-teaching myself. Needless to say I have run into a few obstacles...for instance-Create a *one* line command that, using tar, will collect the full /usr/local directory (you need to run this as root again) and copy the whole /usr/local structure under /optFor example /usr/local/bin/hello will become /opt/local/bin/hello, etc. I want this as follows:1. /usr/local is collected by tar, but the output of this tar command is its stdout.. what you get from the previous stdout, you compress with gzip and send it to stdout again 3. get this output and decompress with gzip.. get this output and pipe to tar in a way that will extract the tree under /opt.If anyone knows how I could go about doing this, please let me know, or at the very least point me in the right direction. What I've got so far (which could be completely wrong) is:tar cvf - usr/local/ | gzip -c - | gunzip -c - | tar xvf -in theory I feel like this should work (except for extracting the tree under /opt...i'm kinda stuck there)
I work with a Debian Squeeze on my laptop and I have a 160GB external hard disk. My hard disk was formatted FAT32, but I decided to format it using ext2. I formatted it using fdisk from command line and everything went well. Unfortunately, when I mount my hard drive(which is auto-mounted from Debian) it has got root both as owner and group. Then I can't write to it because I have no permission to do that. Is there a setting to create an ext2 partition which has as owner the logged system user in order to have right permission every time.
Would anyone be so kind as to point me to a good reference for how use the command line to configure a directory to be shared in the directory properties?I know how to do it using graphical tools such as Nautilus, Konqueror, and Gnome's shares-admin, but I'd like to know how to do with via command line, because, once you know the commands, the command line is always quicker.I guess you could say I'm looking for a command line method for sharing directories in much the same way that chmod sets permissions from the command line.
I am wondering how I would go about creating a .deb file that would extract it's contents to two different folders. I would have one file directory that should be extracted to /opt and I have a second that should bextracted to the current user's home folder and /etc/skel - How would I go about doing this?
I'm taking here about tins of directories, thousands of files. I'm looking to find a command that makes me able to move the results above to another path, and to create that path once it doesn't exist like below:
rying to find a way to generate a PDF file from a text file in a command mode (X is not installed). Is there a simple way to do that?I don't need anything fancy - no special formatting and no images to include, just simple text converted to a PDF format
I have a project due for my Intro to C++ class and we are suppose to generate a file listing that will take an input of a C++ source code with .cpp extension and make a copy of it with a .lst extention that will have a line number preceding each and every line.
I need to create subdirectories in about 300 existing directories - the subdirectory will have the same name in all 300 existing directories. How do I do this using the mkdir command using a regular expression or globbing?