Print N characters in ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print N characters in ksh
# 8  
Old 10-28-2010
Quote:
Originally Posted by iga3725
Doesn't work on AIX.. but works fine on linux... dont know what's the problem :-(

thanks..
Once again..... what does echo ${COLUMNS} return?

---------- Post updated at 11:10 AM ---------- Previous update was at 10:49 AM ----------

---------- Post updated at 11:12 AM ---------- Previous update was at 11:10 AM ----------

Quote:
Originally Posted by iga3725
Doesn't work on AIX.. but works fine on linux... dont know what's the problem :-(

echo $COLUMNS does not retunr nothing..

thanks
make sure that 'resize' is in your $PATH or specify an absolute pathname to it.
try this:
Code:
nawk -v width=$(resize | nawk -F'[=;]' '/COLUMNS/{print $2}') 'BEGIN{$width=OFS="*";print}'


Last edited by vgersh99; 10-28-2010 at 12:28 PM..
# 9  
Old 10-28-2010
DONE!, works perfectly with this last code... :-)

Thanks a lot!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh hidden characters in variables

Hi. I'm getting the following hidden characters \uat the start of a string after I pass in variables from the command line. I only noticed this when I set -x in my KSH script. Can anybody tell me how this happens and how to remove them? Many thanks. + STR=$'\uusername testuser1' + print... (12 Replies)
Discussion started by: user052009
12 Replies

2. Shell Programming and Scripting

ksh check for non printable characters in a string

Hi All, I am trying to find non-printable characters in a string. The sting could have alphanumeric, puntuations and characters like (*&%$#.') but not non-printable (or that is what I think they are called) which are introduced when you copy any text from DOS to unix box. Input string1:... (10 Replies)
Discussion started by: dips_ag
10 Replies

3. Shell Programming and Scripting

comparing special characters in KSH

Hi Guys, I came across a scenario where I have to check the starting character of line in a file. if it is a specile character i.e. "<" gretaer then perform action. I tried serval ways but could not get the work done. Please help me .... Thanks (6 Replies)
Discussion started by: ravi111_07
6 Replies

4. Shell Programming and Scripting

Use awk to print first 6 characters

Hi, i want to use awk to print the first 6 characters of a variable awk -F"|" '$3>0 { print $3 }' z00.unl > z001.unl but $3= 7 digits and i just want to print the first 6 digits. eg 1005779 but i want to print only 100577 (3 Replies)
Discussion started by: dealerso
3 Replies

5. Shell Programming and Scripting

Ksh: Replace backslash characters

Hi All, I have a requirement to read a line from a file with some search string, replace any backslash characters in that line and store in a variable. Shell script: replace.ksh #!/bin/bash file2=input.rtf line=`grep "Invoice Number" ${file2} | head -1 | sed 's/\\//g'` echo "start... (6 Replies)
Discussion started by: prashas_d
6 Replies

6. Shell Programming and Scripting

Print the first four characters of hostname

Hey, I'm trying to print the first four characters of the hostname of a computer. I can get it from using: hostname -s | sed 's/...........$//'" but this is when I know how many characters are in the computer name. I dont understand why some like: hostname -s | sed '/..../p' wont... (7 Replies)
Discussion started by: yxian
7 Replies

7. Shell Programming and Scripting

print 10 characters in series

suppose fileA kanika123ABC 1222222222222222 raciat5678ty 1221123333331121 jessica78ulllo 2233243223333333 so output shud be print only first 10 characters in series and rest remain same kanika123A 1222222222222222 raciat5678 1221123333331121 jessica78u ... (1 Reply)
Discussion started by: cdfd123
1 Replies

8. Shell Programming and Scripting

get last characters in ksh

Hi, Here the way the txt file looks like.. 100|abcd|6899|xyz 112|dlkja|79311| 432|adjkl|1348|iaw I need the last characters after the last '|' .. thanks (5 Replies)
Discussion started by: meghana
5 Replies

9. UNIX for Dummies Questions & Answers

Ksh Checking if string has 2 characters and does not contain digits?

How could I check if a string variable contains at least (or only) 2 characters, and check and make sure that the string does not contain any numeric digits?...I need to know how to do this as simple as possible. and I am using the Ksh shell. Thanks. (1 Reply)
Discussion started by: developncode
1 Replies

10. Shell Programming and Scripting

Print the characters in a word

Hi, How can I split the characters in a word? For Eg: If my input is: command my output should be: c o m m a n d Please help me in doing it so. (5 Replies)
Discussion started by: chella
5 Replies
Login or Register to Ask a Question