joining command results, and substitution


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting joining command results, and substitution
# 1  
Old 04-16-2008
joining command results, and substitution

Hello community

I'd like to join to command results and put it to the same line in one file, how can I do that?

file: a.txt

so when I put Date '+%H:%M' and echo date '+%D' in the file appears 14:44 01/05/08 not
14:44
01/05/08

I like to know how can I make a substituion of a whole line in a file, to put an example I'd like to change the line where the first column it's like 14:44 for 14:44 02/05/08

Thanks
# 2  
Old 04-16-2008
Code:
date '+%H:%M %D'

# 3  
Old 04-17-2008
Ok XD

Let's suppose the commands are different, maybe one is a query to the system with the largest file on a folder and the other is the current date so the result should be:

ls | sort ... | cut .... (or tail) ...
date ...

the result could be "somefile.dat 19/01/12"

not

somefile.dat
19/01/12

Sorry for my bad explanation :_(
# 4  
Old 04-17-2008
don't understand where the issue is......
# 5  
Old 04-17-2008
when I execute a command and put it in a file this is insered as a whole line.

I want to insert the result of two commands in the same line of a file.

ls | sort ... | cut .... (or tail) ... + date ...
# 6  
Old 04-17-2008
Code:
#!/bin/ksh

(ls ; echo -n " $(date '+%H:%M %D') ) | sort ... | cut .... (or tail)

# 7  
Old 04-17-2008
perfect! you are the best!

Thanks, i hope I can use it for "n" commands not 2
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regarding command substitution

Oracle Linux 5.6, 64-bit Given the following snippet wrkvar=`sqlplus -s / as sysdba <<EOF set echo off feedback off head off trimsp on select count(*) from v\$parameter where name in ('db_file_name_convert','log_file_name_convert') and value is not null; EOF` echo wrkvar=$wrkvarProduces... (2 Replies)
Discussion started by: edstevens
2 Replies

2. Shell Programming and Scripting

Substitution within string command

I have the following code: strfuture=abcdefghi ver=${strfuture:${count}:1} mj7777_ver=${ver} start_mj7777_iteration let count=count+1 When it is executed I get bad substitution. The same if I use ver=${strfuture:$count:1} mj7777_ver=${ver}... (6 Replies)
Discussion started by: Bruble
6 Replies

3. Shell Programming and Scripting

sed returns different results while substitution on a pipe delimited file

Hi, Need help with a sed command that I am using to substitute 3 positions of a pipe delimited file. i am getting different results while substituting the same position of two different files with the same value. Please see details below: $ cat chk2 ... (3 Replies)
Discussion started by: vmenon
3 Replies

4. UNIX for Dummies Questions & Answers

read command - using output from command substitution

Hey, guys! Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek: So, I wanted to use a command statement similar to the following. This is kinda taken... (2 Replies)
Discussion started by: ProGrammar
2 Replies

5. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

6. UNIX for Dummies Questions & Answers

Command substitution within an echo

I'm trying to get this to work and I'm not really sure how to do it. echo $x | awk '{print $NF}' MODIFIEDThe output I'm trying to get should look like: dir1 MODIFIED Where dir1 will be the result of: $x |awk '{print $NF}'I'm sure there's something I'm supposed to put around that part... (3 Replies)
Discussion started by: ewoods
3 Replies

7. Shell Programming and Scripting

Need Help with Joining Command or AWK

Hello. I have 2 files. File 1: 1692 @00000000201@00000205@20090402@000015000 1692 @00000000202@00000206@20090402@000010000 263157760@00000000401@00000201@20090402@000056250 510584583@00000000300@00000207@20090402@000030000 571764164@00000000100@00000128@20090402@000000500... (12 Replies)
Discussion started by: crazyhpux
12 Replies

8. Shell Programming and Scripting

Difference between "Command substitution" and "Process substitution"

Hi, What is the actual difference between these two? Why the following code works for process substitution and fails for command substitution? while IFS= read -r line; do echo $line; done < <(cat file)executes successfully and display the contents of the file But, while IFS='\n' read -r... (3 Replies)
Discussion started by: royalibrahim
3 Replies

9. Shell Programming and Scripting

String substitution on find results inside exec/xargs

What I'm trying to do is perform a copy, well a ditto actually, on the results of a find command, but some inline string substitution needs to happen. So if I run this code find ./ -name "*.tif" I get back these results. .//1234567.tif .//abcdefg.tif Now the action from exec or xargs I... (2 Replies)
Discussion started by: myndcraft
2 Replies

10. Shell Programming and Scripting

Substitution of last command

"Is there any substituation of last command or script syntax which can be used as a user. As far I know the "last" command is being used to display information about previous logins. A member of adm group or the user adm can execute it only. Thanks in advance for your usual help. Ghazi (6 Replies)
Discussion started by: ghazi
6 Replies
Login or Register to Ask a Question