Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-15-2009, 09:14 AM   #1
Registered: Aug 2009
Posts: 349

Rep: Reputation: 16
shell script - pipe command

i need to write a script.

we add a static number to the pid of the process which gives us a communication id which the process uses to talk to other processes

we add 73000 to the LINUX PID which gives us the COMMUNICATION ID.

so i need to write some thing like this

echo pidofprocess 73000 | awk { print $1 + $2 } = $variable | ls -ltr $variable

i need to understand how to create substitution values in awk and then transfer them to a linux command.

i do it a hundred times a day running the awk command , then cutting and pasting the result in to the ls -ltr command on the host.

it is time to automate.
Old 08-15-2009, 09:25 AM   #2
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 553Reputation: 553Reputation: 553Reputation: 553Reputation: 553Reputation: 553
bash-3.1$ a=65
bash-3.1$ b=73000
bash-3.1$ let c=a+b
bash-3.1$ echo $c
or did you want them as appended strings?
bash-3.1$ c=$a$b
bash-3.1$ echo $c
Maybe (as someone else said elsewhere) I'm over-simplifying this, or you're over-complicating it but if I've missed the point, please correct me.

Old 08-15-2009, 10:28 AM   #3
Senior Member
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
$ ls -ltr $((pidofprocess + 73000))


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script pipe input - bash mostly laikos Programming 4 11-09-2008 05:14 PM
How can I pipe output of a command into arguments of a script HGeneAnthony Linux - General 3 12-26-2007 06:24 AM
command with shell script sunlinux Programming 2 12-28-2006 11:36 PM
Command in shell script Grassie Coetzee Linux - Software 1 03-13-2005 11:42 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:32 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration