Sponsored Content
Top Forums Shell Programming and Scripting Last line in while do function being ignored Post 303016345 by Don Cragun on Tuesday 24th of April 2018 09:44:57 PM
Old 04-24-2018
The following seems to work with bash on macOS High Sierra (version 10.13.4):
Code:
while IFS= read -r line
do	case "$line" in
		"Your name:"*)   uservar="${line#*: }" ;;
		"Email:"*)       emailvar="${line#*: }" ;;
		"Subject:"*)     subject="${line#*: }" ;;
		"Description:"*) description="${line#*: }" ;;
	esac
done <<-EOF
	$(pbpaste)
EOF
printf 'description="%s"\nemailvar="%s"\nsubject="%s"\nuservar="%s"\n' \
	"$description" "$emailvar" "$subject" "$uservar"

If you were using ksh instead of bash, the code suggested by durden_tyler in post #5 would also work.
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. AIX

function trace back and address to line number conversion

Hi, I am new to AIX and I am developing a small tool for our product which helps debug memory leaks etc. Q1)Is there a way in which i can get a function trace back as to the call (lets say malloc() )has been made in which file--> in which function. I tried using the #pragma options (... (0 Replies)
Discussion started by: Wkdunreal
0 Replies

2. Shell Programming and Scripting

How to send a function all command line args?

I have this code, I thought it would automatically know the args sent to script when called from shell. But it seems to not see any... main script: . args . errors . opt . clean dbfile="" opfile="" # calls function in script below chkarg #check commands (2 Replies)
Discussion started by: gcampton
2 Replies

3. Homework & Coursework Questions

I need to make a script that has 4 command line arguments to function properly.

I have no idea what the following means. The teacher is too advanced for me to understand fully. We literally went from running a few commands over the last few months to starting shell scripting. I am not a programmer, I am more hardware oriented. I wish I knew what this question was asking... (3 Replies)
Discussion started by: Wookard
3 Replies

4. Shell Programming and Scripting

[SOLVED] Awk one line to sum up a function

I need help with debugging an error in my awk script. I have a shell script with variable named U_new_i and want to pass it to awk for use in a summation. The original file have the following content. cat test.txt -2445.7132000000 -2444.9349000000 -2444.3295000000 -2443.1814000000 ... (0 Replies)
Discussion started by: Quantum_Dot
0 Replies

5. Shell Programming and Scripting

Help reading each line and in a function

I have a text file with file names, id like to have this portion of my BASH script go grab the line (which in this case is the full path to my file) then cat that file so I could pipe it to a email. 1) My text file (/tmp/1.txt) is setup like this: ... (3 Replies)
Discussion started by: binary-ninja
3 Replies

6. Programming

Why does gdb stop at a different line than “i b” shows while returning from function?

Here is the program I am trying to debug: #include <stdio.h> int i = 5; int main(void) { int x = 3; display(x); return 0; } void display(int x) { for ( i=0; i<x; ++i ) { printf("i is %d.\n", i); } }This code is coming from here Peter's gdb Tutorial: Stepping... (2 Replies)
Discussion started by: ijustneeda
2 Replies

7. Shell Programming and Scripting

Avoid single line output from function

I am new to shell scripting and wished to get few things clarified. While calling functions within shell script, output comes out as single line irrespective of the no of echos or newlines I tried within function + the echo -e used to invoke function ( as instructed online) : #!/bin/sh inc() {... (1 Reply)
Discussion started by: RMath
1 Replies

8. How to Post in the The UNIX and Linux Forums

GREP function in ksh which ignores LINE Breaks

I am using a grep command with two patterns in my KSH script. File has line breaks in it and both the patterns are in different lines. Here is the command - grep -l 'RITE AID.*ST.820' natriter820u.20140914 Pattern1 - RITE AID Pattern2 - ST*820 I am not getting any results from this,... (3 Replies)
Discussion started by: Raghav Garg
3 Replies

9. UNIX for Dummies Questions & Answers

GREP function in ksh which ignores LINE Breaks

Hello I am using a grep command with two patterns in my KSH script. File has line breaks in it and both the patterns are in different lines. Here is the command grep -l 'RITE AID.*ST.820' natriter820u.20140914 Pattern1 - RITE AID Pattern2 - ST*820 I am not getting any results from... (24 Replies)
Discussion started by: Raghav Garg
24 Replies

10. UNIX for Beginners Questions & Answers

How to find encapsulating function name from line number?

I am looking at a log file which just tells me the filename and the line number inside that file that has the Error. What I am interested is knowing the encapsulating function. For example, here are the contents of the log file Error: foo.file on line wxy Error: foo.file... (3 Replies)
Discussion started by: kaaliakahn
3 Replies
hsfs(7FS)							   File Systems 							 hsfs(7FS)

NAME
hsfs - High Sierra & ISO 9660 CD-ROM file system DESCRIPTION
HSFS is a file system type that allows users access to files on High Sierra or ISO 9660 format CD-ROM disks from within the SunOS operat- ing system. Once mounted, a HSFS file system provides standard SunOS read-only file system operations and semantics. That is, users can read files and list files in a directory on a High Sierra or ISO 9660 CD-ROM, and applications can use standard UNIX system calls on these files and directories. This file system also contains support for the Rock Ridge Extensions. If the extensions are contained on the CD-ROM, then the file sys- tem will provide all of the file system semantics and file types of UFS, except for writability and hard links. If your /etc/vfstab file contains a line similar to /dev/dsk/c0t6d0s0 -/hsfs hsfs -no ro and /hsfs exists, you can mount an HSFS file system with either of the following commands: mount -F hsfs -o ro device-special directory-name or mount /hsfs Normally, if Rock Ridge extensions exist on the CD-ROM, the file system will automatically use those extensions. If you do not want to use the Rock Ridge extensions, use the ``nrr'' (No Rock Ridge) mount option. The mount command would then be: mount -F hsfs -o ro,nrr device-special directory-name Files on a High Sierra or ISO 9660 CD-ROM disk have names of the form filename.ext;version, where filename and the optional ext consist of a sequence of uppercase alphanumeric characters (including ``_''), while the version consists of a sequence of digits, representing the version number of the file. HSFS converts all the uppercase characters in a file name to lowercase, and truncates the ``;'' and version information. If more than one version of a file is present on the CD-ROM, only the file with the highest version number is accessible. Conversion of uppercase to lowercase characters may be disabled by using the -o nomaplcase option to mount(1M). (See mount_hsfs(1M)). If the CD-ROM contains Rock Ridge extensions, the file names and directory names may contain any character supported under UFS. The names may also be upper and/or lower case and will be case sensitive. File name lengths can be as long as those of UFS. Files accessed through HSFS have mode 555 (owner, group and world readable and executable), uid 0 and gid 3. If a directory on the CD-ROM has read permission, HSFS grants execute permission to the directory, allowing it to be searched. With Rock Ridge extensions, files and directories can have any permissions that are supported on a UFS file system; however, despite any write permissions, the file system is read-only, with EROFS returned to any write operations. High Sierra and ISO 9660 CD-ROMs support only regular files and directories, thus HSFS supports only these file types. A Rock Ridge CD-ROM can support regular files, directories, and symbolic links, as well as device nodes, such as block, character, and FIFO. EXAMPLES
Example 1: Sample Display of File System Files If there is a file BIG.BAR on a High Sierra or ISO 9660 format CD-ROM it will show up as big.bar when listed on a HSFS file system. If there are three files BAR.BAZ;1 BAR.BAZ;2 and BAR.BAZ;3 on a High Sierra or ISO 9660 format CD-ROM, only the file BAR.BAZ;3 will be accessible. It will be listed as bar.baz. SEE ALSO
mount(1M), mount_hsfs(1M), vfstab(4) N. V. Phillips and Sony Corporation, System Description Compact Disc Digital Audio, ("Red Book"). N. V. Phillips and Sony Corporation, System Description of Compact Disc Read Only Memory, ("Yellow Book"). IR "Volume and File Structure of CD-ROM for Information Interchange", ISO 9660:1988(E). DIAGNOSTICS
hsfs: Warning: the file system... does not conform to the ISO-9660 spec The specific reason appears on the following line. You might be attempting to mount a CD-ROM containing a different file system, such as UFS. hsfs: Warning: the file system... contains a file [with an] unsupported type The hsfs file system does not support the format of some file or directory on the CD-ROM, for example a record structured file. hsfs: hsnode table full, %d nodes allocated There are not enough HSFS internal data structure elements to handle all the files currently open. This problem may be overcome by adding a line of the form set hsfs:nhsnode=number to the /etc/system system configuration file and rebooting. See system(4). WARNINGS
Do not physically eject a CD-ROM while the device is still mounted as a HSFS file system. Under MS-DOS (for which CD-ROMs are frequently targeted), files with no extension may be represented either as filename. or filename that is, with or without a trailing period. These names are not equivalent under UNIX systems. For example, the names BAR. and BAR are not names for the same file under the UNIX system. This may cause confusion if you are consulting documentation for CD-ROMs originally intended for MS-DOS systems. Use of the -o notraildot option to mount(1M) makes it optional to specify the trailing dot. (See mount_hsfs(1M)). NOTES
No translation of any sort is done on the contents of High Sierra or ISO 9660 format CD-ROMs; only directory and file names are subject to interpretation by HSFS. SunOS 5.10 25 Apr 1994 hsfs(7FS)
All times are GMT -4. The time now is 08:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy