Sponsored Content
Top Forums Shell Programming and Scripting get the last 2 char from a variable Post 86262 by tmarikle on Wednesday 12th of October 2005 04:56:51 PM
Old 10-12-2005
Code:
echo $VAR1 | sed 's/.*\(..\)\..*/\1/'

NT

echo $VAR2 | sed 's/.*\(..\)\..*/\1/'

XP

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace any char with newline char.

Hi, How to replace any character in a file with a newline character using sed .. Ex: To replace ',' with newline Input: abcd,efgh,ijkl,mnop Output: abcd efgh ijkl mnop Thnx in advance. Regards, Sasidhar (5 Replies)
Discussion started by: mightysam
5 Replies

2. Programming

Adding a single char to a char pointer.

Hello, I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it: char* getext(char *file) { char *extension; int i, j;... (5 Replies)
Discussion started by: pallak7
5 Replies

3. Programming

concat const char * with char *

hello everybody! i have aproblem! i dont know how to concatenate const char* with char const char *buffer; char *b; sprintf(b,"result.txt"); strcat(buffer,b); thanx in advance (4 Replies)
Discussion started by: nicos
4 Replies

4. Shell Programming and Scripting

Splitting a variable based on newline char

Heeloo all, A weird problem perhaps. May god save others from this problem. I want to print each line from a variable.. the example below should make it clear. smvar="Hello World1 Hello world 2 forgot there I guess" for eachline in $smvar echo $eachline end Whats for... (3 Replies)
Discussion started by: pavanlimo
3 Replies

5. Shell Programming and Scripting

Replacing one Char in a string of variable length

Hi all, I am trying to find the best way of making a change to 1 char in a string, the string can be between 1 and 14 characters. I am reading a line in from a file which contains 012341231231:2:102939283:NNN: Require :NBN: 012838238232:3:372932:NNN: Require :NNB: I need to change 1 N or a... (8 Replies)
Discussion started by: nkwilliams
8 Replies

6. Shell Programming and Scripting

A variable is including the Carriage Return char...

Hi all, I'm reading a file with this layout: First_Col Second_Col The Second_Col has values as 1000, -1, 10, 43... While reading the file I'm getting the second column value with awk command, but it is including the CR control char. do item_saved=`echo $b | awk '{print... (4 Replies)
Discussion started by: mrreds
4 Replies

7. Programming

error: invalid conversion from ‘const char*’ to ‘char*’

Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially): xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’: xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’ The same error with all c++ constructors - gcc 4.4.4. If anyone can throw any light on... (8 Replies)
Discussion started by: GSO
8 Replies

8. UNIX for Dummies Questions & Answers

Remove newline char from variable

I have a file ABC.DAT with 2 columns avaialble Data format : XYZ!$#$!120 XXZ!$#$!1000 YYZ!$#$!104 While running the following code : FILE_COUNTER=1; RECORD_CN_FILE_COUNT=$((`wc -l ABC.DAT| cut -f1 -d' '`)); while do FILE_NAME=`cat ABC.DAT.DAT| head -$FILE_COUNTER |tail -1 | awk -F... (1 Reply)
Discussion started by: Nikhil Gautam
1 Replies

9. Programming

Invalid conversion from char* to char

Pointers are seeming to get the best of me and I get that error in my program. Here is the code #include <stdio.h> #include <stdlib.h> #include <string.h> #define REPORTHEADING1 " Employee Pay Hours Gross Tax Net\n" #define REPORTHEADING2 " Name ... (1 Reply)
Discussion started by: Plum
1 Replies

10. UNIX for Beginners Questions & Answers

Views How to replace a CRLF char from a variable length file in the middle of a string in UNIX?

My sample file is variable length, with out any field delimiters. It has min of 18 chars length and the 'CRLF' is potentially between 12-14 chars. How do I replace this with a space? I still want to keep end of record, but just want to remove these new lines chars in the middle of the data. ... (7 Replies)
Discussion started by: chandrath
7 Replies
ADDLOINS(3)						       MBK LOGICAL FUNCTIONS						       ADDLOINS(3)

NAME
addloins - create a logical instance ORIGIN
This software belongs to the ALLIANCE CAD SYSTEM developed by the ASIM team at LIP6 laboratory of Universite Pierre et Marie CURIE, in Paris, France. Web : http://asim.lip6.fr/recherche/alliance/ E-mail : alliance-users@asim.lip6.fr SYNOPSYS
#include "mlo.h" loins_list *addloins(ptfig, insname, ptmodel, sigchain) lofig_list *ptfig; char *insname; lofig_list *ptmodel; chain_list *sigchain; PARAMETERS
ptfig Pointer to the figure in which the instance should be added insname Instance name ptmodel Pointer to the instance model sigchain Pointer to chain list of signal pointers DESCRIPTION
addloins creates a new instance, and adds it to the list of instances pointed to by ptfig->LOINS. The new instance is added in front of the list, and becomes itself the list head. The parameter insname fills the INSNAME field of the loins structure. The ptmodel is used for two purposes. First, the ptmodel->NAME fills the FIGNAME field. Second, the connectors of the figure pointed to by ptmodel are duplicated in the LOCON field, but the signals linked to each connector are the one given in the sigchain argument. See chain(3) for details on chain_lists. The matching is done in order, it means that the first connector is linked to the first signal of the sigchain, and so on. Care must be taken when instanciating in order to warranty the validity of the netlist. For details on the structure, see loins(3). RETURN VALUE
addloins returns a pointer to the newly created instance. ERRORS
"*** mbk error *** addloins impossible : instance insname already exist in figure ptfig->NAME" The insname is the instance identifier. So it must be unique at a given hierarchy level. "*** mbk error *** addloins impossible : instance model is the figure figname itself" The model of the instance has the same name that the figure where the instantiation takes place. This check is only performed for a single hierarchy level, in terms of its instances. "*** mbk error *** addloins impossible : connector number discrepancy between figure ptmodel->NAME and instance insname in figure ptfig->NAME" The number of signals in the sigchain is not equal to the number of connectors of the model. The matching is not done correctly. EXAMPLE
#include "mlo.h" void add_na2_y(pt, in1, in2, out) /* add an instance of na2_y */ lofig_list *pt; /* pointer to the figure */ long in1, in2, out; /* signals indexes */ { chain_list *signal = NULL; /* get the pointer when signal index is known */ signal = addchain(signal, (void *)givelosig(pt, in1)); signal = addchain(signal, (void *)givelosig(pt, in2)); signal = addchain(signal, (void *)givelosig(pt, out)); /* get vdd and vss */ signal = addchain(signal, (void *)give_vdd(pt)); signal = addchain(signal, (void *)give_vss(pt)); /* reverse the list */ signal = reverse(signal); addloins(pt, "nand", getlofig("na2_y"), signal); } SEE ALSO
mbk(1), lofig(3), loins(3), chain(3), getloins(3), delloins(3). BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory. We need your feedback to improve documentation and tools. ASIM
/LIP6 October 1, 1997 ADDLOINS(3)
All times are GMT -4. The time now is 02:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy