I need to combine output of two commands.
For example:
If I input ls -l && file *
it will give me
-rw-rw-r-- 1 user user 1356 2012-01-21 07:45 string.c
-rwxrwxr-x 1 user user 7298 2012-01-21 07:32 string_out
-rw-rw-r-- 1 user user 777 2012-01-18 21:44 test
string.c: ASCII C program text, with CRLF line terminators
string_out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
test: POSIX shell script text executable
but what I want is:
-rw-rw-r-- 1 user user 1356 2012-01-21 07:45 string.c string.c: ASCII C program text, with CRLF line terminators
-rwxrwxr-x 1 user user 7298 2012-01-21 07:32 string_out string_out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
-rw-rw-r-- 1 user user 777 2012-01-18 21:44 test test: POSIX shell script text executable
Any suggestions how to do this?
Linux allows you to enter multiple commands at one time. The only requirement is that you separate the commands with a semicolon. Running the combination of commands creates the directory and moves the file in one line.
On Linux, there are three ways to run multiple commands in a terminal: The Semicolon (;) operator. The Logical OR (||) operator. The Logical AND (&&) operator.
Concatenate Commands With “&&“ The “&&” or AND operator executes the second command only if the preceding command succeeds.
paste
is your friend here. Using bash process substitution:
paste <(ls -l | sed 1d) <(file *)
edit: added sed command to delete first line of ls output ("total: xx")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With