Sponsored Content
Top Forums Shell Programming and Scripting Screwy Characters or Inferior Command? Post 302341839 by durden_tyler on Thursday 6th of August 2009 05:06:15 PM
Old 08-06-2009
Quote:
Originally Posted by mrwatkin
...
Can anyone please let me know of a different command that I can do to make this spaced values effect without the other values being chopped off? I'll be doing this to pass these values into an array.
...
You can use Perl. After you SFtp the script to Linux and before you run the "grep" command, do this -

Code:
perl -pi.bak -e 's/\r//g' someScript.sh

The weird output of the grep command is due to the "carriage return" character "\r" (ASCII decimal 13), which moves the cursor to the first position of the same line thereby forcing the 2nd line to overwrite the first line. (The "\r" comes from files created in Windows.)

Code:
$
$ echo `grep SomeVariable= someScript.sh | cut -d"=" -f2`
 someValue2
$
$ echo `grep SomeVariable= someScript.sh | cut -d"=" -f2` | od -bc
0000000 163 157 155 145 126 141 154 165 145 015 040 163 157 155 145 126
          s   o   m   e   V   a   l   u   e  \r       s   o   m   e   V
0000020 141 154 165 145 062 015 012
          a   l   u   e   2  \r  \n
0000027
$
$

So -

Code:
$
$ # Using Perl to remove the carriage return characters
$
$ perl -pi.bak -e 's/\r//g' someScript.sh
$
$ echo `grep SomeVariable= someScript.sh | cut -d"=" -f2`
someValue someValue2
$

The ".bak" backs up your script before applying the changes.

HTH,
tyler_durden
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Command to get only the Three Characters of the Month

Hi, Please let me know if I can format the output of the date command to three character month name. For example,if I type date and enter, it should give the Month name in the following format: Jan or Feb or Mar etc i.e, only the first three characters of the month name. Please respond... (2 Replies)
Discussion started by: prashanth_gs
2 Replies

2. UNIX for Dummies Questions & Answers

Sed command with characters

Hi everyone, I hope that someone can help me out: In the following line: PRIHDR;2809999444;2007 6.1;20070423;9;;4021473000003;;4021473000003;8714231530688;EUR;; The output should be: PRIHDR;2809999444;2007 6.1;20070423;4;;4021473000003;;4021473000003;8714231530688;EUR;; I've tried... (7 Replies)
Discussion started by: IHulky
7 Replies

3. Shell Programming and Scripting

get characters from output of a command in a variable

Hi, i have two questions, I am new to programming 1. I have an output of a command and i want to get some specific part of it in a variable. i am trying sr=`some comand xyz| grep 'Last Changed Rev:' | cut -c19-` now variable sr gets a end of line character at end. output of the command... (3 Replies)
Discussion started by: muaz
3 Replies

4. Shell Programming and Scripting

exclude characters in echo command please help

Hi all, I wrote one code and i face some difficulties to exclude some characters from the echo command more specifically the last command is echo $a "${RESULT}" >> results_data_srcip the results which i have taken are: nfcapd.200908250000 -.352228 nfcapd.200908250005 -.345085 ... (4 Replies)
Discussion started by: draxmas
4 Replies

5. Shell Programming and Scripting

Grep command to count characters

I have a file that I need to count the number of "Y"s in the file, but just the "Y"s that fall between certain columns. Like: file1: 1234567890123456789012345 BBBBBBYBBBBYBBYBBYBBYBBB I want to count the 'Y's between 17 and 21 = 2 "Y"s Thanks (12 Replies)
Discussion started by: jbt828
12 Replies

6. Shell Programming and Scripting

Using awk with the date command and escape characters

I have a file that is a log file for web traffic. I would like to convert the timestamp in it to unix time or epoch time. I am using the date command in conjunction with awk to try to do this. Just myfile: 28/Aug/1995:00:00:38 1 /pub/atomicbk/catalog/home.gif 813 28/Aug/1995:00:00:38 1... (3 Replies)
Discussion started by: jontjioe
3 Replies

7. UNIX for Dummies Questions & Answers

sed command to remove characters help!

I am trying to analyse a large file of sequencing data, example of first 10 lines below, @HWUSI-EAS656_0044_FC:7:1:2447:1039#GCAATT/1 GNCTATGGCTTGCCGGGCTCAGGGAAGACAATCATAGCCATGAAAATCATGGAAAAGATCAGAAAAACATTTCAA +HWUSI-EAS656_0044_FC:7:1:2447:1039#GCAATT/1... (1 Reply)
Discussion started by: Adeleh
1 Replies

8. Shell Programming and Scripting

Special characters in command arguments

Hey Guys, I have a program that populates a database based on input I feed it. so it would look like: cmd arg1 arg2 ... argN Now some of the arguments have special characters in them so I wrote a small script to pull the args and wrap them in quotes ('arg'). The problem is sometimes... (10 Replies)
Discussion started by: aaron0001
10 Replies

9. Shell Programming and Scripting

Ps command and awk - shorten characters

ps -e -o pcpu -o pid -o user -o args | sort -k 1 | tail -6r %CPU PID USER COMMAND 0.3 223220 root /usr/tivoli/tsm/client/ba/bin/dsmc sched 0.2 411332 root /usr/sbin/syslogd 0.1 90962 root /usr/sbin/syncd 60 0.0 10572 root -ksh 0.0 94270 root -ksh ... (4 Replies)
Discussion started by: SkySmart
4 Replies

10. Shell Programming and Scripting

Using CURL command with special characters in URL

Hi. I 'm trying to hit a REST api and retrieve a JSON feed, and the URL has special characters in it. Something like: Example Domain The below curl command is failing curl -X GET https://www.example.com/?sample=name&id=1001 saying bad command at id=1001 I am going to use this as part... (3 Replies)
Discussion started by: kumarjt
3 Replies
ISALPHA(3)						   BSD Library Functions Manual 						ISALPHA(3)

NAME
isalpha -- alphabetic character test LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <ctype.h> int isalpha(int c); DESCRIPTION
The isalpha() function tests for any character for which isupper(3) or islower(3) is true. The value of the argument must be representable as an unsigned char or the value of EOF. In the ASCII character set, this includes the following characters (preceded by their numeric values, in octal): 101 ``A'' 102 ``B'' 103 ``C'' 104 ``D'' 105 ``E'' 106 ``F'' 107 ``G'' 110 ``H'' 111 ``I'' 112 ``J'' 113 ``K'' 114 ``L'' 115 ``M'' 116 ``N'' 117 ``O'' 120 ``P'' 121 ``Q'' 122 ``R'' 123 ``S'' 124 ``T'' 125 ``U'' 126 ``V'' 127 ``W'' 130 ``X'' 131 ``Y'' 132 ``Z'' 141 ``a'' 142 ``b'' 143 ``c'' 144 ``d'' 145 ``e'' 146 ``f'' 147 ``g'' 150 ``h'' 151 ``i'' 152 ``j'' 153 ``k'' 154 ``l'' 155 ``m'' 156 ``n'' 157 ``o'' 160 ``p'' 161 ``q'' 162 ``r'' 163 ``s'' 164 ``t'' 165 ``u'' 166 ``v'' 167 ``w'' 170 ``x'' 171 ``y'' 172 ``z'' RETURN VALUES
The isalpha() function returns zero if the character tests false and returns non-zero if the character tests true. COMPATIBILITY
The 4.4BSD extension of accepting arguments outside of the range of the unsigned char type in locales with large character sets is considered obsolete and may not be supported in future releases. The iswalpha() function should be used instead. SEE ALSO
ctype(3), isalnum_l(3), islower(3), isupper(3), iswalpha(3), ascii(7) STANDARDS
The isalpha() function conforms to ISO/IEC 9899:1990 (``ISO C90''). BSD
July 17, 2005 BSD
All times are GMT -4. The time now is 03:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy