Sponsored Content
Top Forums Shell Programming and Scripting Removing Letters from Integer String Post 37096 by oombera on Thursday 12th of June 2003 10:50:01 AM
Old 06-12-2003
Well, you could use
Code:
echo "1024MB" | awk '{print substr($1,0,4)}' # print first four numbers / chars
echo "1024MB" | sed 's/[A-Za-z]*//g'         # removes all letters
x=${x%%[A-Za-z]*}           # remove everything after (and including) any chars


Last edited by oombera; 06-12-2003 at 12:27 PM..
 

10 More Discussions You Might Find Interesting

1. Programming

Integer to String

Which function should I use to convert an Integer to a String or Char format ? Thanx (2 Replies)
Discussion started by: psilva
2 Replies

2. Shell Programming and Scripting

Checking if string contains integer

G'day guys, first post so be gentle. I need help with some code to work out if a variable (string) contains any integers. The valid variable (string) must contain only letters. Also need to be able to work out if a variable contains only integers. Any help greatly appreciated. (7 Replies)
Discussion started by: haz
7 Replies

3. Shell Programming and Scripting

Comparing string and integer in IF

hi, I need to create an IF condition. I read a line from a file and get the 5 word using space as a delimited. This word can have only two values either '*' or '1-5' I need to write an IF condition for two cases. I can either compare it to * or 1-5(or even 1 by cutting and getting only the... (3 Replies)
Discussion started by: kaushys
3 Replies

4. UNIX for Dummies Questions & Answers

integer to string

Hi all, is there an easy way to convert integer to string in bash? I have numbers like 1, 2, ..., 112, ... and I would like to get 001 002 003 004 ... Thank you, Sarah (4 Replies)
Discussion started by: f_o_555
4 Replies

5. Shell Programming and Scripting

how to compare string integer with an integer?

hi, how to I do this? i="4.000" if ; then echo "smaller" fi how do I convert the "4.000" to 4? Thanks! (4 Replies)
Discussion started by: h0ujun
4 Replies

6. Homework & Coursework Questions

passing letters from an array into a string for string comparison

attempting the hangman program. This was an optional assignment from the professor. I have completed the logical coding, debugging now. ##I have an array $wordString that initializes to a string of dashes ##reflecting the number of letters in $theWord ##every time the user enters a (valid)... (5 Replies)
Discussion started by: lotsofideas
5 Replies

7. Shell Programming and Scripting

Checking subset and removing extra letters

In each line of file, I wish to check if word1 is a non-connected subset of any of the other words in the line. If yes, keep only the words that ward1 is a subset of. Else, remove the whole line. Also, I want to remove the letters that word1 doesn't match with, except for "_+" Example file:... (2 Replies)
Discussion started by: Viernes
2 Replies

8. Shell Programming and Scripting

awk : match only the pattern string , not letters or numbers after that.

Hi Experts, I am finding difficulty to get exact match: file OPERATING_SYSTEM=HP-UX LOOPBACK_ADDRESS=127.0.0.1 INTERFACE_NAME="lan3" IP_ADDRESS="10.53.52.241" SUBNET_MASK="255.255.255.192" BROADCAST_ADDRESS="" INTERFACE_STATE="" DHCP_ENABLE=0 INTERFACE_NAME="lan3:1"... (6 Replies)
Discussion started by: rveri
6 Replies

9. Shell Programming and Scripting

String to integer

I am on HP-UX using ksh in the script. MaxSal=`sqlplus -silent /nolog <<EOF connect / as sysdba whenever sqlerror exit sql.sqlcode set pagesize 0 feedback off verify off heading off echo off select max(sal) from emp1; select max(sal) from emp2; select max(sal) from emp3; exit; EOF`... (3 Replies)
Discussion started by: bang_dba
3 Replies

10. UNIX for Beginners Questions & Answers

Removing letters after a certain character within a range of columns

Hi there, I am trying to remove al letters after : character on specific columns from 10th column till 827. I used sed and cut to do so but I am sure there is better one liner someone can think of from unix community members. Huge file but it has this structure (Total number of Columns =... (10 Replies)
Discussion started by: daashti
10 Replies
VT-IS-UTF8(1)							Linux User's Manual						     VT-IS-UTF8(1)

NAME
vt-is-UTF8 - check whether current VT is in UTF8- or byte-mode. SYNOPSIS
vt-is-UTF8 [-h|--help] [-V|--version] [-q|--quiet] DESCRIPTION
vt-is-UTF8 checks whether the current VT is in UTF8 mode, by writing (and erasing afterwards) a 3-byte-long UTF8 sequence, and looking how much chars where displayed by the console driver. A message telling in which mode the console is is then written to stdout (except if the --quiet option was given). If the --quiet option is not given, the value returned is 1 if an error occurs, else 0. OPTIONS
-h --help display version number, a short help message and exit. -V --version display version number and exit. -q --quiet do not print on stdout in with mode we are, but return the state as exit-status 1 if in UTF8-mode, 0 if in byte-mode. In case of error, 0 is returned and a message is displayed on stderr. BUGS
The check should be done by directly asking the kernel, which is not possible as of kernels 2.0.x. As of kernel 2.0.35, the byte-mode is sometimes erroneously detected as UTF8-mode, after switching from a 512-chars font to a 256-chars font. This is probably a console-driver bug. SEE ALSO
unicode_start(1), unicode_stop(1). Console tools 10 Aug 1998 VT-IS-UTF8(1)
All times are GMT -4. The time now is 12:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy