Cutting strings from output of command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cutting strings from output of command
# 1  
Old 12-13-2011
Cutting strings from output of command

Hi,

I am new to scripting and need help in cutting strings from output of a command. For exapmle in am getting the following as the out out from the command i run:

Out Condition: Askajdsdfa | date: 1204 | oper: +


I need to get the output as Askajdsdfa and 1204.

Thanks
# 2  
Old 12-13-2011
Code:
command_I_run | awk -F '|' '{print $1,$2 }' | sed 's/date://'

One way of many to do this.
# 3  
Old 12-14-2011
Code:
cmd | awk -F '[|:]' '{print $1,$3 }'

--ahamed
# 4  
Old 12-14-2011
Thanks all for your replies. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract strings from output

I am having the following output when executing a dig command : dig @1.1.1.1 google.com +noall +answer +stats ; <<>> DiG 9.11.4-P1 <<>> @1.1.1.1 google.com +noall +answer +stats ; (1 server found) ;; global options: +cmd obodrm.prod.at.dmdsdp.com. 86154 IN A ... (1 Reply)
Discussion started by: liviusbr
1 Replies

2. UNIX for Beginners Questions & Answers

Cutting disk space output

Running this code df -h | head -2 | awk '{print $8}' Gives me the following output: %iused 6% What I'm trying to do is get the 6% but I'm having trouble doing this using cut -c, I think that this could be because the text is on different lines; is there a way of doing this? (8 Replies)
Discussion started by: $shell_Learner
8 Replies

3. Shell Programming and Scripting

Insert title as output of command to appended file if no output from command

I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place. What I need The following command is placed at the prompt: TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies

4. Programming

Print only some strings from an output

Hi, Here is an example: I have a grep line: grep -i -r -H "$WORD" "$DIRECTORY"with an output like this: /media/dir/dir2//dir4/file.txt:/media/dir/dir2/dir3/file_16072008/es6.txt: "content of the file found from grep"/media/dir/dir2/dir3/dir4/file3.txt:/media/dir/dir2/dir3//file.txt:"other... (3 Replies)
Discussion started by: Hornys
3 Replies

5. Shell Programming and Scripting

Concatenating strings to "tr" command output

Hi All, Please help me in forming command for the following scenario. My input string (msg)is \'01\',\'02\',\'03\',\'04\',\'05\',\'06\' , i have removed \ and ' using echo $msg|tr -d '\\'|tr -d "'" which gave me output as 01,02,03,04,05,06. I am half done here. Now i want to append... (8 Replies)
Discussion started by: chpsam
8 Replies

6. Shell Programming and Scripting

Getting specific strings from output

so i have the following string: ... (3 Replies)
Discussion started by: SkySmart
3 Replies

7. Shell Programming and Scripting

combining cat output and cutting rows

I have a file that contain the following. -D HTTPD_ROOT="/usr/local/apache" -D SERVER_CONFIG_FILE="conf/httpd.conf" I want a shell script, so that after cat filename and apply the shell script I should get the output as follows. /usr/local/apache/conf/httpd.conf ie cat filename |... (7 Replies)
Discussion started by: anilcliff
7 Replies

8. Shell Programming and Scripting

Cutting Part of Output

Hello all I'm using bourne shell and need to figure out how to cut out a specific portion of some output. For example, my output from my command is: 12.12.52.125.in-addr.arpa name = hostname.domain.main.gov I need to get just the "hostname.domain.main.gov" part. What I'm trying... (9 Replies)
Discussion started by: lee.n.doan
9 Replies

9. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies

10. AIX

CUT command - cutting characters from end of string

Hello, I need to delete the final few characters from a parameter leaving just the first few. However, the characters which need to remain will not always be a string of the same length. For instance, the parameter will be passed as BN_HSBC_NTRS/hub_mth_ifce.sf. I only need the bit before the... (2 Replies)
Discussion started by: JWilliams
2 Replies
Login or Register to Ask a Question