Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Redirect from Variable to command line?? Post 302069583 by ugh on Monday 27th of March 2006 04:33:50 PM
Old 03-27-2006
Bug

This script takes a data file and allows you to remove the columns you dont want.

runme.sh datafile.txt "|" 2,4

This will ouput only data that would fall under 2nd and 4th column

filename=$1
dell=$2
keep=$3

echo $keep | awk -F"," '{ORS=" " }{OFS=""}{gtw=","} {for(i=1;i <=NF;i++){ print
"$",$i,gtw; if((i+1) == NF) gtw="" } }' | read output

i="awk -F\"$dell\" 'BEGIN{OFS=FS}{print $output}' $filename"

echo $i>temp.sh
chmod 700 temp.sh
temp.sh
rm temp.sh

Its just alot easier building the awk command this way.
Thank you very much vgersh99...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

redirect command output to variable

Hi, I am looking for a way to redirect the result from a command into a variable. This is the scenario. Using the find command I will be getting multiple records/lines back. Here is the command I am using: find /”path”/ -name nohup.out -print This now is giving me the paths and file... (1 Reply)
Discussion started by: hugow
1 Replies

2. UNIX for Dummies Questions & Answers

redirect stderr and/or stdout to /dev/null from command line

Is it possible to redirect errors at the command line when you run the script such as bash scriptname & 2>/dev/null? (1 Reply)
Discussion started by: knc9233
1 Replies

3. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

4. Shell Programming and Scripting

variable redirect messing up a sed command.

Not sure if that title is decent, but here we go. I'm running this string of commands: qstat -f $1 | sed 's/^*//' | sed -n -e ":a" -e "$ s/\n//gp;N;b a" | sed 's/\\,/,/' | awk -F"PBS_O_WORKDIR=" '{print $2}' | awk -F",PBS_O_SYSTEM" '{print $1}'In case you're curious is takes the output of a PBS... (3 Replies)
Discussion started by: dhibbit
3 Replies

5. Shell Programming and Scripting

Input variable in command line

i have this script that reads a file "listall_101111" where 101111 varies. awk '{print $0,$1}' listall_101111 | sed -e 's/\(.*\).$/\1/g' | awk '{print $6,$2,$3,$4,$5}' | sort -nrk5 | nawk 'NR==1{m=$5;a++;b=(b)?b:$0;next}$5==m{a++;b=(b)?b:$0}END{for (i in a){print b,a}}' | grep -v ^LG | sort... (4 Replies)
Discussion started by: aydj
4 Replies

6. Shell Programming and Scripting

Using redirect for input instead of command line

I have a script that is working when I input parameters from the command line. I was under the assumption that i could use a redirect for the input. script fred.sh: value1=$1 value2=$2 print $value1 $value2 Running from command line: fred.sh 1 2 1 2 Contents of file fred.txt:... (3 Replies)
Discussion started by: djm2112
3 Replies

7. Shell Programming and Scripting

SH script, variable built command fails, but works at command line

I am working with a sh script on a solaris 9 zone (sol 10 host) that grabs information to build the configuration command line. the variables Build64, SSLopt, CONFIGopt, and CC are populated in the script. the script includes CC=`which gcc` CONFIGopt=' --prefix=/ --exec-prefix=/usr... (8 Replies)
Discussion started by: oly_r
8 Replies

8. Shell Programming and Scripting

Redirect output of command line to for loop

I would like to redirect output of command line in for loop as $line. Output should be processed as line but instead it throw whole output. Could somebody help me on how to redirect output of command line and process it line by line without sending output to any file. below is my code ... (1 Reply)
Discussion started by: tapia
1 Replies

9. Shell Programming and Scripting

How to redirect output of a command to a variable during ftp mode?

Hi, How can I redirect the output of a following command to a variable. ftp myservername ftp> user (username) guptaji 331 Password required for guptaji. Password: ftp> size /home/salil/abc.dat ftp> a='size /home/salil/abc.dat' ?Invalid command I want to redirect value of size to... (1 Reply)
Discussion started by: Salil Gupta
1 Replies

10. Shell Programming and Scripting

How to read the output of a command line by line and pass it as a variable?

Hi, I have some 2000 names in a table like below. Java Oracle/SQL ANSI SQL SQL,DWH,DB DB&Java And by using for loop in my code i am able to get a single word but if there is any special character or space then it is considering as a next line. I have to execute the below queries in... (10 Replies)
Discussion started by: Samah
10 Replies
Net::SIP::Redirect(3pm) 				User Contributed Perl Documentation				   Net::SIP::Redirect(3pm)

NAME
Net::SIP::Redirect - Send redirect to Requests based on lookup at a registrar SYNOPSIS
my $reg = Net::SIP::Registrar->new(...); my $redir = Net::SIP::Redirect( dispatcher => $dispatcher, registrar => $reg, ); DESCRIPTION
This package implements a simple redirection of Requests using the information provided by a registrar. CONSTRUCTOR
new ( %ARGS ) This creates a new redirect object, %ARGS can have the following keys: dispatcher Net::SIP::Dispatcher object manging the registar. Mandatory. registrar Registrar object. This is an object like a Net::SIP::Registrar, which has a "query(address)" method which returns a list of contacts. METHODS
receive ( PACKET,LEG,FROM ) PACKET is the incoming packet, LEG is the Net::SIP::Leg where the packet arrived and FROM is the "ip:port" of the sender. Responses will be send back to the sender through the same leg. Called from the managing Net::SIP::Dispatcher object if a new packet arrives. Will return "()" and ignore the packet if it's an REGISTER request. For Requests it will query the registrar and return either "302 Moved Temporarily" with the list of contacts or "404 Not found" if the address is not registered. perl v5.14.2 2010-05-31 Net::SIP::Redirect(3pm)
All times are GMT -4. The time now is 07:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy