Sponsored Content
Top Forums Shell Programming and Scripting Using :<<cut / cut to comment out block of bash script Post 303021960 by MadeInGermany on Tuesday 21st of August 2018 01:36:26 PM
Old 08-21-2018
bash 4.x wants the ending cut on a single line, otherwise it issues a warning at the very last line (while bash 3.x and ksh do not issue a warning).
The other error is from substitution in the here-document. Any $( ) or $(( )) or ${} or $var is evaluated and substituted by the result.
You can suppress this substitution by putting the delimiter word in quotes.
Code:
: <<"cut"
here-document with $(( % 0 ))
cut

The most confusing thing with your script is that in normal code mode the shell sees the # and treats the line as a comment. However in a here-document the shell does not see a #comment.

Last edited by MadeInGermany; 08-21-2018 at 02:47 PM..
This User Gave Thanks to MadeInGermany For This Post:
 

4 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

cut usage in bash

Hello, Could you put some light on this: > echo "ref_categorie=test" | cut -c1-15- test > echo "ref_categorie=test" | cut -c1-14- =test echo "ref_categorie=test" | cut -c15- test echo "ref_categorie=test" | cut -c15 t > It's executed on AIX if that matters. The man page is not very... (2 Replies)
Discussion started by: tsurko
2 Replies

2. Shell Programming and Scripting

Cut out string in bash script

Hi all, I'm trying to extract string from variable in BASH. That's probably trivial for grep but I couldn't figure it out. I want to get name, there's sometimes digit after it, but it should be left out. STRING=http://name5.domain.com:8000/file.dat Could someone help me with that? Any... (10 Replies)
Discussion started by: cootue
10 Replies

3. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

4. UNIX for Beginners Questions & Answers

Cut command: can't make it cut fields

I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
Discussion started by: scrutinizerix
9 Replies
VIEW-OS(1)						      General Commands Manual							VIEW-OS(1)

NAME
mstack - networking stack selection SYNOPSIS
mstack [-hv] [-o protocol list] stack_mountpoint command DESCRIPTION
In View-OS multiple networking stacks are available to processes at the same time. View-OS supports the msocket(2) system call. mstack defines the default stack (for each address family) that is used when msocket refers to a NULL pathname for its stack. mstack provides also a backward compatibility for all the programs using the obsolete socket(2) system call. The stack mountpoint identifies the stack. In ViewOS it is the mountpoint where the stack was mounted (by mount(2)(8). In fact the call: "socket(domain,type,protocol)" is equivalent to: "msocket(NULL,domain,type protocol)" mstacks changes the default stack for the desired protocol families and executes the command (by execve(2)). OPTIONS
-h prints the mstack command usage -v sets the verbose mode on -o defines the list of protocols. Without a -o option, mstack redefines the default stack for all protocols families. The list of proto- cols may include the a comma separated sequence of the following items: all, unix (or simply u), ipv4 (4), ipv6 (6), netlink (n), packet (p), bluetooth (b), irda (i), ip (which include all ip related protocols ipv4, ipv6, netlink and packet), #n where n is the num- ber of protocol. Each item can be prefixed by + or - to specify whether the protocol/group of protocols must be added or removed from the set. EXAMPLES
mstack /dev/net/lwip ip addr lists the address managed by the stack mounted on /dev/net/lwip. exec mstack /dev/net/null bash disables the standard stack in a new bash (which overcomes the current one). mstack -o ip /dev/net/lwip bash starts a new bash which uses the stack /dev/net/lwip for ipv4 and ipv6 but not for the other protocols. mstack -o -unix /dev/net/lwip bash starts a new bash which uses the stack /dev/net/lwip for all protocols but AF_UNIX. mstack -o +ip,-ipv6 /dev/net/lwip bash starts a new bash which uses the stack /dev/net/lwip for ipv4, netlink, packet but not ipv6. SEE ALSO
umview(1), kmview(1), msocket(3), umnetnative(9), umnetnull(9), umnetlwipv6(9), unix(7), ip(7), ipv6(7), netlink(7), packet(7). AUTHORS
View-OS is a project of the Computer Science Department, University of Bologna. Project Leader: Renzo Davoli. <http://www.sourceforge.net/projects/view-os> Howto's and further information can be found on the project wiki <wiki.virtualsquare.org>. VIEW-OS: a process with a view April 23, 2008 VIEW-OS(1)
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy