Tag Info

New answers tagged

0

rsync -avz LIB_COMMON/ LIB_CZ/ LIB_RESULT/ --delete-after This will sync the content of lib_common/ & lib_cz/ to lib_result/ folder.


0

This answer to a different question helped: http://stackoverflow.com/a/22558474/652971 Here's how I would do this: rsync $( find ./one/ -type f $(printf "! -name %s " `ls ./two/`) find ./two/ -type f ) user@remote:/path/


5

The root directory is /. The themes directory in the root directory is /themes. A path that starts with / is called an absolute path; it starts from the root directory. A path that doesn't start with / is called a relative path; it starts from the current directory of the program where you use it. For example, a bare file name with no directory indication is ...


-4

cd into the folder then execute the following command: ls |xargs rm -rf


1

The sequence of commands you give clones the grub repository, changes the current directory to that newly created by git (cd grub), builds grub, changes the directory to grub-core, and runs the grub-mkimage executable which is in the parent directory. More explicitly, if you start off in your home directory (I'll imagine it's /home/evan): git clone ... ...


1

The $HOME environment variable is commonly set and exported by login to the pathname of a user's home directory when a user logs in. A POSIX-compatible shell will use the value of this environment variable in a context when it should perform a ~ tilde expansion to complete a path to a username's home directory but the actual expanded field is otherwise null. ...


2

In shell, user's home directory is located in /home/username, ~ is shortcut for home directory of the current user using the shell, ~usr is shortcut for home directory of user with username usr, so ~usr is the same as /home/usr. If your username is usr, then ~ and ~usr are the same. The home directory of current user is also saved in variable $HOME.


6

Whatever you're saying about ~$, home$, and /home$ doesn't make much sense.  I guess you're talking about your command line prompt; if so, it would have been useful to show what you typed and what happened (and then explained what you expected). But I can read minds, so I believe that I understand the issue: ~ and ~user239887 (assuming user239887 is your ...


0

Dot meaning "this directory" dot dot meaning prev directory. When the file or directory start with dot meaning "hide" "Hide" for ls or other commands, not for FS. So if you run ls /home/foo you don't see files or directory starting with dot. If you run "rm -r /home/foo/*" all files will be delete. Not the files or directories starting with dot. Now, in case ...


3

With zsh, you could do: mkdir -p ~/.zsh/dirhist And add to your ~/.zshrc: HISTSIZE=1000 SAVEHIST=10000 setopt HIST_SAVE_NO_DUPS INC_APPEND_HISTORY HISTFILE=~/.zsh/dirhist/${PWD//\//@} chpwd() { [[ $PWD = $OLDPWD ]] || fc -Pp ~/.zsh/dirhist/${PWD//\//@} } chpwd() is called whenever the current directory changes. There, we reset the history file to ...


1

Short answer: cd .system Longer answer: You do not see the .system directory when you run ls because the dot in front makes it "hidden". To see it, run ls with the -a flag: $ ls -a /mnt/fn . .. .system You can always just do: $ cd /mnt/fn/.system


4

.. and then cd .system. The presence of a dot at the start of really doesn't mean much of anything except to make it "hidden" - i.e. it won't appear in a default ls listing unless you specify -a.


1

The tar command does not zip. Not even with the -z flag. However, it does collect a series of files/folders and optionally compress the result. To contrast, zip compresses each file and adds it to an archive. zip and tar use different compression algorithms. The man page for tar shows the -C flag (--directory) to change directory, so you could do this tar ...


2

You can try following: tar -czf ./zips/someFile.tar.gz -C ./tmp/ someFolder


1

You can use the parameter -C or --directory tar -czf ./zips/someFile.tar.gz -C ./tmp someFolder From man tar -C, --directory DIR change to directory DIR Example % ls -og total 4 -rw-rw-r-- 1 0 Mai 21 18:39 bar drwxrwxr-x 2 4096 Mai 21 18:39 foo tar -cvf ../sample.tar -C /home/user/tmp . tar -tvf ../sample.tar drwxrwxr-x user/user 0 ...


1

The Unix/Linux/*BSD kernel has always kept track of working directory. The chdir() and fchdir() system calls have been around for as long as the C language has been around. If you write a C language program and use execve(), it's up to your program to specify the filename argument of execve(). The kernel will find executables in the current working ...


8

Not a neat answer but an alternative if you're using bash as your shell: you could createt some alias in your .bashrc. For instance: alias a='cd /tmp/A ; history -w ; history -c ; export HISTFILE=/home/user/.a_history ; history -r $HISTFILE' alias b='cd /tmp/B ; history -w ; history -c ; export HISTFILE=/home/user/.b_history ; history -r $HISTFILE' Then, ...


2

Yes, it is possible by setting up the search path appropriately (either containing your working directory explicitly or by containing "./"), but it is good practice to have the "./" in front of the program name. The reason is security: A malware could write an executable file with the name of a commonly used program (say, ls) and the next call to ls will ...


1

Well a quick workaround would be creating an alias. This creation can be added to the .bashrc to have it added during startup.


2

You should better define what is the "other process" and what method it uses to launch a program. In any case, the current working directory is a property of each and every process running so it might be used to locate a program to run. Whether it is safe to implement it that way is questionable.


0

You can remove directory using following command: sudo rm -r directoryname1/2/3/* It will be delete entire directory after 3/*. Example sudo rm -r Downloads/song/* It will be delete all files which are within Downloads/song.


0

I had the same thing happen to me tonight after using the Pendrivelinux Universal USB installer to create the bootable usb, however, my problem disappeared after I tried using the rawrite utility to write the mint CD image to my USB drive. (I suppose dd would work if you're creating the usb on a linux system)


2

/bin is probably a symlink to /usr/bin on your system. If that were true then: /bin/../sfw/bin/zsh would actually be the same as /usr/bin/../sfw/bin/zsh which reduces to /usr/sfw/bin/zsh which is where zsh actually lives. Note that what you tried, which was /bin/sfw/bin does not correspond to any path that you actually could see on the system. ...


0

The other answers here were fine but were insufficient for my needs. I needed a solution that I could use in my scripts on any machine. My solution was to write a shell script which I can invoke from the scripts where I need it. #!/bin/sh if [ $# -eq 0 ] || [ $# -gt 2 ]; then printf 'Usage: respath path [working-directory]\n' >&2 exit 1 fi ...


0

Note that if you want to know all {sub}folders size inside a directory, you can also use the -dor --max-depth option of du (which take an argument: the recursive limit) For instance : du -h /path/to/directory -d 1 Will show you something like 4.0K /path/to/directory/folder1 16M /path/to/directory/folder2 2.4G /path/to/directory/folder3 68M ...


-1

tar -cf foo.tar foo/ | xz -9 foo.tar Generates foo.tar.xz at -9 compression WITHOUT streaming, which yields a smaller file. Streaming in LZMA inflates the file by a few bytes.


0

If you are able to use find and if you are working on a "normal Unix filesystem" (that is, as defined in find(1) under -noleaf option description), then the following command can be used: find . -type d -links 2 Each directory has at least 2 names (hard links): . and its name. Its subdirectories, if any, will have a .. pointing to the parent directory, so ...


1

One of the other answers came close to this: find . -type d -exec sh -c 'cd "$0" && cmd' {} \; (running the command only if the cd succeeds).  Some people recommend inserting a dummy argument, so the found directory ({}) slides over to $1: find . -type d -exec sh -c 'cd "$1" && cmd' foo {} ";" Of course, you can use any string here in place of foo.  ...


5

The find command is powerful, but that makes it a little challenging to use. I'm pretty sure it can do what you need - this command below is "almost" what you ask for: find . -type d -execdir pwd \; But - this does not run the command in the deepest directory level - it runs in the directories in which other directories are found. So it wil run in ...


6

Solution Using Parallel You could use GNU Parallel for a compact, faster solution. find . -type d -print0 | parallel -0 cd {}'&&' <command-name> This will work absolutely fine, even for directory names containing spaces and newlines. What parallel does here is that it takes the output from find, which is every directory and then feeds it to ...


0

You can use something like this find /home/test/ -type d -exec bash -c '<Command to be executed>' \; Example: The below command will display the dirname, similar to running a pwd command. find /home/test/ -type d -exec bash -c 'echo $0' \;


0

You don't need to run extra pwd command you can run the following command: find test/ -type d You can replace your directory with test/


1

On Unix and Unix-like systems, . means the current directory. For example, ls . is the same as ls, it will list the contents of the current directory. So, when you run ./Desktop it finds a directory called Desktop that is under your current directory. You then get an error telling you that this is a directory and, therefore, cannot be executed as it is not a ...


0

The first shouldn't be an relative location. An relative location is to notate things shorter from within the location in which you're. An absolute location is from the root / which is the first directory location in Linux. When you aren't in /var you can use cd /var/www as /var/www an absolute location is. If you're in /var you can use cd ./www ...


1

Sample explanation: / (slash) means root, from the root of the filesystem. So, /home/yogesh/Desktop/Books starts from the root, then checks for home, under home check for yogesh and so on. This is called an absolute path. . (dot) means starting from current directory. So, if your current directory is /home/yogesh and you check for ./Desktop, it is there. ...


1

On unix (like on Windows), /foo is the location of a file or directory (absolute location, from the root directory: /). Whereas ./foo is a relative location (relative to the current directory)... You can omit the leading dot + slash and just write foo. By typing the command /Desktop or ./Desktop, you tell the shell to execute Desktop... Which can't be ...


0

I followed the suggestion here: http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html and never looked back. The key to this utility is that "cd" will follow symbolic links to directories, and a shell function which looks something like: export JJPATH=$HOME/.jjlinks function jj { cd -P "$JJPATH/$1" ...


0

This is not exactly what you are asking for, but you may want to take a look at Z (works in bash and zsh) which tracks your most used directories, based on 'frecency' and let you jump around. In your example it would be something like: z software and it would probably change the directory to: /home/work/software


2

I don't know what shell you're using, but zsh has built-in support for this. It's called named directories. To set this up, add code like the following to .zshrc: mywork=/home/work/software #set variable : ~mywork #Reference variable with a tilde in a no-op statement Then you can use it at the command line like this: $ cd ~mywork Or this: $ cd ...


-1

I think this utility might be what you are looking for: http://micans.org/apparix/


1

It sounds like setting CDPATH could get you close to what you are asking: cd cd [-L|[-P [-e]] [-@] [directory] Change the current working directory to directory. [...] If the shell variable CDPATH exists, it is used as a search path: each directory name in CDPATH is searched for directory, with alternative directory names in ...


1

inode 0 is used as a NULL value, to indicate that there is no inode. indoe 1 is used to keep track of any bad blocks on the disk; it is essentially a hidden file containing the bad blocks. Those bad blocks which are recorded using e2fsck -c. indoe 2 is used by the root directory which indicates starting of File system inodes


0

In ext4 the Inode 1 is used for bad blocks. The link below the the kernel site describes which Inode is used for what purpose. https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Special_inodes


5

With zsh: printf '%s\n' **/*(D^om/:t) Those are glob qualifiers, a feature unique to zsh at this time. D: include dot-files ^: reverse the following qualifiers om: order on modification time (reversed with ^) /: exclude (with ^) files of type directory. :t: a modifier that gets the tail of the file (the basename). (if you want the full path as opposed ...


1

find . ! -name . -prune -print | grep -c / Should be fairly portable to post-80s systems. That counts all the directory entries except . and .. in the current directory. To count files in subdirectories as well: find .//. ! -name . | grep -c // (that one should be portable even to Unix V6 (1975), since it doesn't need -prune)


0

Assuming the application runs with it's own account, which has it's own group: chown root:app_group apptmpdir && chmod 770 apptmpdir (or whatever permissions it needs) Only the owner of a file/dir, or root, is allowed to change permissions. Thus, by making root own it, the application won't be able to change the permissions.


0

I consider it an ugly solution, but yes, you can block any file or inode changes as well as prevent a file or directory being moved by setting it "immutable": chattr +i [file] Occasionally useful, but it can cause confusion down the line when you've forgotten what you did, and nothing you seem to do can modify it.


9

Any file on a conventionally designed UNIX filesystem whose reference count (e.g. the sum of the hardlink count and the number of open file handles*) reaches 0 is removed. However, on modern UNIX systems, the rmdir system call removes an empty directory in a single operation rather than removing . and .. one-by-one. In historical UNIX systems, however, this ...


7

Firstly not all filesystems use . and .. as hard links. this is documented in the gnu find manual. I am going to ignore those filesystems for the rest of my answer because they were not designed for unix and only complicate things without adding clarity. I am also going to ignore the root directory and mount points for the same reason. the number of links ...


3

Think of a directory as a text file that looks something like: 123:foo.txt 234:bar.txt 123:other-name-for-foo.txt That's all there is (at least in traditional Unix file systems). foo.txt is not a child of that directory in that it's not an exclusive relationship. It's just that the file of inode number 123 is referenced in two entries of that directory: ...



Top 50 recent answers are included