Sponsored Content
Top Forums Shell Programming and Scripting BASH- Need help pulling data from .emlx Post 302875923 by neutronscott on Wednesday 20th of November 2013 10:26:04 PM
Old 11-20-2013
small improvements. not that it's likely you'll have % in your filenames, but you should use printf properly: printf '%s\tFAIL\t\n' "$filename"

if using bash you'd also want read -r to disable backslash processing too.

examples:
Code:
mute@thedoctor:~$ read var <<< 'file\name'; echo "$var"
filename
mute@thedoctor:~$ read -r var <<< 'file\name'; echo "$var"
file\name
mute@thedoctor:~$ filename='%strange'; printf "$filename\tOK\n"
trange  OK

These 2 Users Gave Thanks to neutronscott For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pulling data and following lines from file

I saw a few posts close to what i want to do, but they didn't look like they would work exactly.. or I need to think out of the box on this. I have a file that I keep server stats in for my own performance analysis. this file has the output from many commands in it (uptime, vmstats, ps, swap... (2 Replies)
Discussion started by: MizzGail
2 Replies

2. Shell Programming and Scripting

SFTP to server, pulling data and removing the data

Hi all, I have the following script, but are not too sure about the syntax to complete the script. In essence, the script must connect to a SFTP server at a client site with username and password located in a file on my server. Then change to the appropriate directory. Pull the data to the... (1 Reply)
Discussion started by: codenjanod
1 Replies

3. Shell Programming and Scripting

Bash script pulling variable from query_string

I have a variable embedded in a long string called "commands" coming in on a query_string. I need to copy the string to a file with the variable $loop1 converted before it writes. Right now, it writes the varible itself instead of what it should be. QUERY_STRING... (2 Replies)
Discussion started by: numele
2 Replies

4. Shell Programming and Scripting

Help with pulling / filtering data from a .csv

Good day Gurus, I have a csv file that contains an inventory of active servers. This csv file contains a well over a hundred systems (IBM, SUN, HP). It also contains those systems details. See below for an example hostA,invver,1.02,20100430 hostA,date,08/30/2010,06:18 hostA,use,"Unknown... (4 Replies)
Discussion started by: LuffyDMonkey
4 Replies

5. Shell Programming and Scripting

Basic bash -- pulling files from an FTP server

Hi guys. Very new to this so apologies if this is ridiculously obvious, but I am not sure why this isn't working. I want to pull a file off an FTP server. I currently do it through windows, which is no problem, but I want to move everything to a Linux box I just installed. wget won't work as the... (4 Replies)
Discussion started by: majormajormajor
4 Replies

6. Shell Programming and Scripting

Pulling data from xml

Hi there, Please could anyone help with this. I have an xml file that contains repeating values eg <Rule name> AAAAA <Action> BBBBB </Action> <Data> CCCCC </Data> <Type> DDDDD </Type> </Rule name> <Rule name> A1A1A1A1 <Action> B1B1B1B1 </Action> <Data> C1C1C1C </Data> <Type>... (4 Replies)
Discussion started by: ssideel
4 Replies

7. Shell Programming and Scripting

Pulling Data, Then Moving to the Next File

I'm scanning a list of emails- I need to pull 2 pieces of data, then move to the next file: Sender's Email Address Email Date I need these to be outputted into a single column- separated by a ",". Like this: Email1's Address, Email1's Date Stamp Email2's Address, Email2's Date Stamp... (4 Replies)
Discussion started by: sudo
4 Replies

8. Shell Programming and Scripting

Pulling information from a data file by date

awk -v now="$(date +%s)" -v tDiff="${USERMINUTES}" ' BEGIN { FS="=" if (!now) now=systime() if (!tDiff) tDiff=60*60 p=1 } /{/ {rec=$0;p=1;next} /}/ && rec && p {print rec ORS $0;next} $1=="entry_time" { if (now-$2>tDiff)p=0 } {rec=rec ORS $0}'... (6 Replies)
Discussion started by: SkySmart
6 Replies

9. Shell Programming and Scripting

Bash: Pulling first and last character in string

I am writing a bash script that will find all references to the “Well_List” in the “Comp_File”. I am filtering a Well_List that contains the following: TEST_WELL_01 TEST_WELL_02 TEST_WELL_11 TEST_WELL_22 GOV_WELL_1 GOV_WELL_201 PUB_WELL_57 PUB_WELL_82 . . Comparison... (5 Replies)
Discussion started by: petfyp
5 Replies
read(1) 						      General Commands Manual							   read(1)

NAME
read - Reads a line from standard input SYNOPSIS
read [-r] var... STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: read: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Do not treat a backslash character in any special way. Consider each backslash to be part of the input line. Note The -r option is included to enable read to subsume the purpose of the obsolete line utility. OPERANDS
The name of an existing or non-existing shell variable. DESCRIPTION
The read utility reads a single line from standard input. By default, unless the -r option is specified, backslash () acts as an escape character. If standard input is a terminal device and the invoking shell is interactive, read prompts for a continuation line in the following cases: The shell reads an input line ending with a backslash, unless the -r option is specified. A here-document is not terminated after a newline character is entered. The line is split into fields as in the shell (see the sh(1) reference page); the first field is assigned to the first variable var, the second field to the second variable var, and so forth. If there are fewer var parameters specified than there are fields, the leftover fields and their intervening separators are assigned to the last var. If there are fewer fields than vars, the remaining vars are set to empty strings. The setting of variables specified by the var parameters affects the current shell execution environment. If read is called in a subshell or separate utility execution environment, such as one of the following, it does not affect the shell variables in the caller's environ- ment: (read foo) nohup read ... find . -exec read ... ; NOTES
The -r option is included to enable read to subsume the purpose of the obsolete line utility. RESTRICTIONS
The results are undefined if an end-of-file is detected following a backslash at the end of a line when -r is not specified. EXIT STATUS
The following exit values are returned: Successful completion. End-of-file was detected or an error occurred. EXAMPLES
The following command prints a file with the first field of each line moved to the end of the line: while read -r xx yy do printf "%s %s " "$yy" "$xx" done < input_file ENVIRONMENT VARIABLES
The following environment variables affect the execution of read: Determines the internal field separators used to delimit fields. Pro- vides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization variables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization vari- ables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale used to affect the format and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. Provides the prompt string that an interactive shell will write to standard error when a line ending with a backslash is read and the -r option was not specified, or if a here-document is not terminated after a newline character is entered. SEE ALSO
Commands: line(1) Functions: fread(3) Standards: standards(5) read(1)
All times are GMT -4. The time now is 01:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy