Sponsored Content
Top Forums Shell Programming and Scripting awk alias passing a value to a variable Post 302649747 by cokedude on Friday 1st of June 2012 03:59:19 AM
Old 06-01-2012
awk alias passing a value to a variable

I am trying to turn this into an alias with no luck. I would then like to put the alias into my bashrc file. I know awk is very picky about quotes. I have tried every version of quotes, single quotes, double quotes, and backslashes that I can think of.

Code:
VAR=$(xrandr | awk '$2=="connected"{s=$1} END{print s}'); xrandr --output $VAR --mode 1024x768 --rate 60; xrandr --output LVDS1 --left-of $VAR; xrandr --output LVDS1 --primary; unset VAR;

This what it looks like just trying to copy it into an alias. I would really prefer an alias over a function or creating a shellscript.

Code:
$ alias xx2='VAR=$(xrandr | awk '$2=="connected"{s=$1} END{print s}'); xrandr --output $VAR --mode 1024x768 --rate 60; xrandr --output LVDS1 --left-of $VAR; xrandr --output LVDS1 --primary; unset VAR;'
bash: alias: END{print: not found
bash: alias: s}); xrandr --output $VAR --mode 1024x768 --rate 60; xrandr --output LVDS1 --left-of $VAR; xrandr --output LVDS1 --primary; unset VAR;: not found

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Passing a variable into an awk script

Hello all, I'm trying to run a script of this format - for i in $(cat <file>); do grep $i <file1>|awk '{print $i, $1, $2}' It's not working - does anyone know how this can be done? Khoom (5 Replies)
Discussion started by: Khoomfire
5 Replies

2. UNIX for Dummies Questions & Answers

Passing a Shell Variable to awk

Hello, I have a file with 4 columns. An arbitrary example is shown below: a Tp 10 xyz b Tq 8 abc c Tp 99 pqr d Tp 44 rst e Tr 98 efg Based on the values in col 2 and col 3, I will execute another program. I have been running this:... (5 Replies)
Discussion started by: Gussifinknottle
5 Replies

3. Shell Programming and Scripting

Passing variable to awk

Hi, I'm new with this stuff, but I hope you can help me. This is what I'm trying to do: for id in $var; do awk '{if ($1 == $id) print $2}' merg_data.dat > neigh.tmp done I need that for every "id", awk search the first column of the file merg_data.dat which contains "id" and... (3 Replies)
Discussion started by: matteo86
3 Replies

4. UNIX for Dummies Questions & Answers

Passing variable to Alias in Hp kshell

Hi all, I have a series of directories which i open regularly. I want create an alias so that i can pass the direcotry name to alias and then this commands makes Cd to the path i need. COuld you please help on how to create an alias ex of what i am trying but couldn't succeeded #alias... (1 Reply)
Discussion started by: firestar
1 Replies

5. Shell Programming and Scripting

Passing multiple variable to awk

Hi , can I pass more then one variable to awk using -v option? (4 Replies)
Discussion started by: Anupam_Halder
4 Replies

6. Shell Programming and Scripting

Passing awk variable argument to a script which is being called inside awk

consider the script below sh /opt/hqe/hqapi1-client-5.0.0/bin/hqapi.sh alert list --host=localhost --port=7443 --user=hqadmin --password=hqadmin --secure=true >/tmp/alerts.xml awk -F'' '{for(i=1;i<=NF;i++){ if($i=="Alert id") { if(id!="") if(dt!=""){ cmd="sh someScript.sh... (2 Replies)
Discussion started by: vivek d r
2 Replies

7. Shell Programming and Scripting

Passing external variable to awk

Hi, I am trying to write a bash script in which I need to pass a external variable to the awk program. I tired using -v but it not accepting the value. Here is my sample code. #!/usr/bin/bash ###################################################################################### ####... (5 Replies)
Discussion started by: jpkumar10
5 Replies

8. Shell Programming and Scripting

awk programming -Passing variable to awk for loop

Hi All, I am new to AWK programming. I have the following for loop in my awk program. cat printhtml.awk: BEGIN -------- <some code here> END{ ----------<some code here> for(N=0; N<H; N++) { for(M=5; M<D; M++) print "\t" D ""; } ----- } ... (2 Replies)
Discussion started by: ctrld
2 Replies

9. UNIX for Dummies Questions & Answers

Passing Shell Variable to awk

Hello All, May i please why my shell variable is not getting passed into awk script. #!/bin/bash -vx i="1EB07C50" /bin/awk -v ID="$i" '/ID/ {match($0,/ID/);print substr($0,RSTART,RLENGTH)}' /var/log/ScriptLogs/keys.13556.txt Thank you. (1 Reply)
Discussion started by: Ariean
1 Replies

10. Shell Programming and Scripting

awk with passing variable

I have file called in in.txt contains with the below lines I want to display the lines between the value which I would be passing. one two three four five ten six seven eight Expected output if I have passed one and ten two three four five (8 Replies)
Discussion started by: mychbears
8 Replies
MKOCTFILE(1)						      General Commands Manual						      MKOCTFILE(1)

NAME
mkoctfile - Compile dynamic-load modules for GNU Octave SYNOPSIS
mkoctfile [-IDIR] [-DDEF] [-lLIB] [-LDIR] [-M|--depend] [-c] [-o FILE|--output FILE] [-p VAR|--print VAR] [-s|--strip] [-v|--ver- bose] [-h|-?|--help] file ... DESCRIPTION
mkoctfile is used to compile source C, C++ or Fortran source code in dynamically loadble file for octave(1). OPTIONS
mkoctfile accepts the following options: -IDIR Add include directory DIR to compile commands. -DDEF Add definition DEF to compiler call. -lLIB Add library LIB to link command. -LDIR Add library directory DIR to link command. -M|--depend Generate dependency files (.d) for C and C++ source files. -c Compile but do not link. -o FILE|--output FILE Output file name; default extension is .oct. -p VAR|--print VAR Print configuration variable VAR. Recognized variables are: CPPFLAGS CPICFLAG INCFLAGS CXX F2C CXXFLAGS F2CFLAGS CXXPICFLAG F77 XTRA_CFLAGS FFLAGS XTRA_CXXFLAGS FPICFLAG SHLEXT CC SH_LD CFLAGS SH_LDFLAGS -s|--strip Strip the output file. -v|--verbose Echo commands as they are executed. file Compile or linke file. Recognised file types are .c C source .cc C++ source .C C++ source .cpp C++ source .f Fortran source .F Fortran source .o object file .SH SEE ALSO .BR octave (1). AUTHOR
John W. Eaton <jwe@bevo.che.wisc.edu> This manual page was contributed by Dirk Eddelbuettel <edd@debian.org> for the Debian GNU/Linux distribution but may be used by others. GNU Octave 1 November 2002 MKOCTFILE(1)
All times are GMT -4. The time now is 03:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy