Sponsored Content
Full Discussion: If statement with pipeline
Top Forums Shell Programming and Scripting If statement with pipeline Post 302866223 by Skrynesaver on Monday 21st of October 2013 03:01:05 PM
Old 10-21-2013
Quote:
Originally Posted by blackrageous
I wonder if the syntax is correct. Have you run whatever contains that statement? What shell are you using?
It works just fine with gnu bc
 

9 More Discussions You Might Find Interesting

1. Programming

C program help please! input from pipeline

I have a project where I have to use bzcat to uncompress a file and use that output as the data to run another program on. I understand that you would do (bzcat filename.bz2 ! program name) but then how do you access that data in the c program??? Please help thanks (2 Replies)
Discussion started by: kinggizmo
2 Replies

2. UNIX for Dummies Questions & Answers

Unix Pipeline help

Does anyone know how to answer this? I have tried many different commands, I just cant get it right..... Search the file 'data' for all of the lines that contain the pattern 'unx122' and put those lines in the file 'matches'. (2 Replies)
Discussion started by: netmaster
2 Replies

3. Shell Programming and Scripting

Comments within a shell pipeline

I've got a very ugly pipeline for analyzing web server logs (but nevermind the application; I've come across this in other scripts as well). I want to nicely comment the steps in the pipeline, but I can't seem to do it. I know, for instance that in csh/sh/bash, a # begins a comment, and any... (2 Replies)
Discussion started by: otheus
2 Replies

4. Shell Programming and Scripting

Retaining Pipeline values

Hi, I am trying to calculate a few values using the below code but it dosent seem to be working. for i in 1 2 3 4 5 6 7 8 do j=`expr $i + 3` x =`head -$j temp1|tail -1|cut -f24 -d","` y =`head -$j temp1|tail -1|cut -f25 -d","` c =`expr $x / $y` echo "$c" >> cal_1 done I am not... (4 Replies)
Discussion started by: sachinnayyar
4 Replies

5. Shell Programming and Scripting

Shell pipeline help for a n00b

I need to read input from a file, and make sure nothing prints after column 72. basically, ignore input after character 72 until the next newline character. Any help is appreciated. I have been searching forever! (10 Replies)
Discussion started by: Gbear
10 Replies

6. Shell Programming and Scripting

uniq -c in the pipeline

Hello gurus - I must be missing something, or there is a better way - pls enlighten me I'm on a Solaris 10 vm running the following pipeline to reduce some apache logs (actually lynx dumps of /server-status/ when threads are above a threshold) to a set of offending DDoS IP addresses. awk... (10 Replies)
Discussion started by: fletch00
10 Replies

7. Shell Programming and Scripting

Change the delimiter from Comma to Pipeline

Hello All, I need to convert a csv file to pipeline delimiter file in UNIX. The data in file itself contains comma with double qouted qualifier apart from the comma separator. Let me know how to do it. Appreciate any help if awk can be used to do it. Mentioned below is the sample record of... (14 Replies)
Discussion started by: Arun Mishra
14 Replies

8. Shell Programming and Scripting

Command pipeline trouble

Hello, I am attempting to ssh to a server and run a set of commands on a remote set of servers. I am getting the following error below, I am thinking quotes may be the problem. This command works on the local machine in bash. Not when I ssh to a remote server. Basically the command should... (3 Replies)
Discussion started by: jaysunn
3 Replies

9. Shell Programming and Scripting

Using cat and pipeline to execute script

hi this is a homework assignment i need some help with it mostly works. script file #!/usr/bin/env bash #create dictionary file grep -E '.{3}' /usr/share/dict/british-english > db.txt #create remove_word to test file touch removeW.txt #palindrome function palin() { ... (1 Reply)
Discussion started by: crepe6
1 Replies
SHELL-QUOTE(1p) 					User Contributed Perl Documentation					   SHELL-QUOTE(1p)

NAME
shell-quote - quote arguments for safe use, unmodified in a shell command SYNOPSIS
shell-quote [switch]... arg... DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands or files with embedded white space or shell globbing characters safely. Here are a few examples. EXAMPLES
ssh preserving args When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and passes them to "$SHELL -c". This doesn't work as intended: ssh host touch 'hi there' # fails It creates 2 files, hi and there. Instead, do this: cmd=`shell-quote touch 'hi there'` ssh host "$cmd" This gives you just 1 file, hi there. process find output It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote: eval set -- `find -type f -print0 | xargs -0 shell-quote --` debug shell scripts shell-quote is better than echo for debugging shell scripts. debug() { [ -z "$debug" ] || shell-quote "debug:" "$@" } With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can. save a command for later shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are things the user can't pass through), you can do something like this: user_switches= while [ $# != 0 ] do case x$1 in x--pass-through) [ $# -gt 1 ] || die "need an argument for $1" user_switches="$user_switches "`shell-quote -- "$2"` shift;; # process other switches esac shift done # later eval "shell-quote some-command $user_switches my args" OPTIONS
--debug Turn debugging on. --help Show the usage message and die. --version Show the version number and exit. AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions. AUTHOR
Roderick Schertler <roderick@argon.org> perl v5.8.4 2005-05-03 SHELL-QUOTE(1p)
All times are GMT -4. The time now is 07:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy