I have:  $ find 1 2 -printf '%i %p\n' 40011805 1 40011450 1/t 40011923 1/a 40014006 1/a/e 40011217 1/a/q 40011806 2 40011458 2/y 40011924 2/a 40013989 2/a/e 40013945 2/a/w   I want:  &lt;inode&gt;  &lt;path&gt; any      2 40011450 2/t 40011458 2/y any      2/a 40014006 2/a/e 40011217 2/a/q 40013945 2/a/w   How do do it?
121605
I'm trying to merge two directory trees that have many common elements but also each have elements that are only present in one of the two trees. The main issue I am having is that when mv encounters two sub-directories with the same relative paths it either keeps the source (with -f) or the destination (with -n) but I can't make it take the union of both sub-directories. I could of course use rsync with --remove-source-files but this will actually copy the data and then delete the old files as opposed to a true move. The two directory trees contain several hundred GB of data and are both on same partition so I would love to do a true move if possible for the sake of time.   Right now I have find * -type file -exec mv -n {} /destination/{} but this only moves  files from the source to the destination when the target directory already exists. I can preface this command with something like mv -n * /destination/ but this only brings over the top level directories. Is there any way to do this in a single line? I could  always write a script to check if the directory exists before copying the file but this seems like such a basic task, it seems like there should be an easier way.
105112
I'm trying to use printf to format some pretty output in a bash script  e.g.:    -----------------------   | This is some output |  -----------------------   But I've stumbled over some behavior I don't understand.  $ printf "--"   gives me the error:     printf: usage: printf [-v var] format [arguments]   and   $ printf "-stuff"   results in      -bash: printf: -s: invalid option   So apparently printf thinks I'm trying to pass some arguments while I'm not.  Meanwhile, completely by accident, I've found this workaround:    $ printf -- "--- this works now ----\n"   gives me   --- this works now ----   Can anyone explain this behavior?
44735
I have got the directory called Test and a few directories inside it. Both Test and the directories inside it have executable files. I'd like to print them with ls. I'd use this command.  ls -l `find Test/ -perm /u=x,g=x,o=x -type f`   Is this a good/right/quick command or not?  My solution is:  find Test/ -executable -type f -exec ls -l {} \;   and got the same result as warl0ck and pradeepchhetri offered.
99936
In Perl, I can type:  $|++;   and anything printed to STDOUT will be automatically fflush()ed.  Is there an equivalent in C? In other words, is there some way I can tell stdio to automatically fflush stdout after every printf(), the way it automatically flushes stderr?
111951
The idea would be to use it as... a pipe in a command. For instance: say there's some kind of long path which has to be retyped again and again, followed by a pipe and a second program, i.e.  "directory1/directory2/direcotry3/file.dat | less -I "   I'd like that part to be stored in a variable, so it could be used like this:  r="directory1/directory2/direcotry3 \| less -I -p " $ cat path1/path2/$r &lt;searchterm&gt;   Instead, I get  cat: invalid option -- I Try `cat --help' for more information.   ... meaning the pipe clearly didn't work.
100532
The runtime arguments are as follows: $1 is the path to the file containing the list of files $2 is the path to the directory containing the files What I want to do is check that each file listed in $1 exists in the $2 directory  I'm thinking something like:  for f in 'cat $1' do if (FILEEXISTSIN$2DIRECTORY) then echo '$f exists in $2' else echo '$f is missing in $2' sleep 5 exit fi done   As you can see, I want it so that if any of the files listed in $1 don't exist in the directory $2, the script states this then closes. The only part I can't get my head around is the (FILEEXISTSIN$2DIRECTORY) part. I know that you can do [ -e $f ] but I don't know how you can make sure its checking that it exists in the $2 directory.
5673
I have a function that is effectively a replacement for print, and I want to call it without parentheses, just like calling print.  # Replace print $foo, $bar, "\n";  # with myprint $foo, $bar, "\n";   In Perl, you can create subroutines with parameter templates and it allows exactly this behavior if you define a subroutine as  sub myprint(@) { ... }   Anything similar in PHP?
69182
I'd like to print a man style usage message to describe a shell function like this output man find:  NAME        find - search for files in a directory hierarchy  SYNOPSIS        find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]  DESCRIPTION        This  manual  page  documents the GNU version of find.  GNU find searches the directory tree rooted at each        given starting-point by evaluating the given expression from left to  right,  according  to  the  rules  of        precedence  (see section OPERATORS), until the outcome is known (the left hand side is false for and opera‐        tions, true for or), at which point find moves on to the next file name.  If no  starting-point  is  speci‐        fied, `.' is assumed.  OPTIONS   I am facing an error message on the ` character. Following simple script shows the error:  ~$ cat &lt;&lt;EOF `.' EOF  bash: bad substitution: no closing "`" in `.'   I though heredoc was a cool way to echo strings by pasting them without having to escape its content such a quotes, etc... I assume I was wrong :/  Can someone explain this behavior please? Can heredoc accept ` character?  Edit 2: I accepted the answer of quoted here-document  &lt;&lt;'END_HELP', but I finally won't use it for this kind of complete manual output as  does   Edit 1: (For future reads) the limit with using quoted here-document is that is prevents to use tput in the here-document. To do so, I did the following:   unquoted here-document, for tput commands to be executed prevent the "bad substitution" error by escaping the backtick instead use tput within the  here-document   Example:  normal=$( tput sgr0 ) ; bold=$(tput bold) ;  cat &lt;&lt;END_HELP # here-document not quoted ${bold}NAME${normal}        find - search for files in a directory hierarchy  ${bold}SYNOPSIS${normal}        find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]  ${bold}DESCRIPTION${normal}        This  manual  page  documents the GNU version of find.  GNU find searches the directory tree rooted at each        given starting-point by evaluating the given expression from left to  right,  according  to  the  rules  of        precedence  (see section OPERATORS), until the outcome is known (the left hand side is false for and opera‐        tions, true for or), at which point find moves on to the next file name.  If no  starting-point  is  speci‐        fied, \`.' is assumed. END_HELP  unset normal ; unset bold ;   Here, note the escaped backtick that was source of error:  \`.'
84523
If I am having a line as:  Thhiisss iisss mmyyy nameeee   I want to print this as:  This is my name   What is the unix command for this?
45888
In ~/my/path, I want to move all files that contain string "(J)" and have file type of ".foo" to ~/my/path/j  I'm trying:  [me ~/my/path]$ find -type f -name "*(J)*.foo" -print0 | xargs mv -0 j/  No luck :(
12202
Say I have the following files:   |-- bar `-- foo     |-- type_A_1     |-- type_A_2     |-- type_B_1     |-- type_B_2     |-- type_B_xx     |-- type_B_xx     `-- something_else    I thought the following command  print -l foo/*~{type_B*}   would print everything under foo except things that start with type_B but it doesn't, instead it prints everything under foo:  foo/type_A_1 foo/type_A_2 foo/type_B_1 foo/type_B_2 foo/type_B_xx foo/something_else   I also tried print -l foo/*~type_B and got the same thing.  How does the exception wildcard ~ work in zsh?
18451
I have a 2 files with the following:   File1.txt  A 1 B 2 C 5 Z 3  File2.txt A 4 B 7  C 10 D 11   What I would like to do is create something like   A 1 4  B 2 7 C 5 10 D - 11 Z 3 -   Is there a utility that does this? If not how Can this be done? Using a find and awk or something?
109570
I have a find command:  find Directory/{Alpha,Bravo,Charlie} arg1 arg2   I want to replace Alpha,Bravo,Charlie with $find_dir  find Directory/{$find_dir} arg1 arg2   however the latter expands to   find Directory/{Alpha,Bravo,Charlie} arg1 arg2   rather then   find Directory/Alpha Directory/Bravo Directory/Charlie arg1 arg2   Why? It's part of a fairly complex bash script that may have more or less directories, not all which are relevant (so globbing Upload/* would not work). So if I setup three now and add another, I'll have to manually add it in later. Plus I need it run from the root of directories to keep finds outputs perspective (./Upload/Dir/file as opposed to ./Dir/file).   But using a variable would permit me to change that as needed and keep it relevant to other parts of the script.
84966
I want to execute a command for an each file that matches a pattern. But the command that seems to be right, doesn't work for me, I have no idea why.  $ find . -type f -name '*.c' -or -name '*.h' -or -name '*.cpp' -exec ls {} \; $ ls script.sh  test.c  test.h
45658
I want to use printf to print a variable. It might be possible that this variable contains a % percent sign.  Minimal example:  $ TEST="contains % percent" $ echo "${TEST}" contains % percent $ printf "${TEST}\n" bash: printf: `p': invalid format character contains $   (echo provides the desired output.)
104430
What would be a more straight forward readable way of these commands?  And why exit 255 and not exit 1?  [ $# -eq 3 ] || { echo error ; exit 255 ; }  grep -q "string" &amp;&amp; exit 0
75928
I know of this command:  find /path/to/mountpoint -inum &lt;inode number&gt;   but it is a very slow search, I feel like there has to be a faster way to do this. Does anybody know a faster method?