The Philippine Electronics and Technology Forum
February 09, 2012, 07:17:12 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  

Pages: [1]   Go Down
  Print  
Author Topic: Basic Scripting PLEASE help Badly needed :(  (Read 542 times)
bbench
Size C Battery
*****

Pogi/Ganda Points: 13
Offline Offline

Gender: Female
Posts: 141


:) :D :D :D :)


WWW
« on: April 05, 2010, 10:32:20 PM »

 Cry  who can help me po pls...... I need to write a unix script (Bourne shell compatible)
Logged

bench!
The Philippine Electronics and Technology Forum
« on: April 05, 2010, 10:32:20 PM »

 Logged
tiktak
Gas Turbine
**

Pogi/Ganda Points: 171
Offline Offline

Gender: Male
Posts: 2498



WWW
« Reply #1 on: April 05, 2010, 10:53:35 PM »

^oi tol anong kalokohan yan? hehe anong gagawin ba ng script? more info please Cheesy
Logged

Bakit andaming hindi marunong gumamit ng search?Huh
zer0w1ng
Technical People
Gas Turbine
*****

Pogi/Ganda Points: 295
Offline Offline

Gender: Male
Posts: 2151


Enter any 11-digit prime number to continue...


WWW
« Reply #2 on: April 06, 2010, 07:22:25 AM »

:'(  who can help me po pls...... I need to write a unix script (Bourne shell compatible)


What will be the purpose of the bash script?
I may be able to help.

For a start here is a intro HOWTO on bash scripting: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Logged

zer0w1ng
Technical People
Gas Turbine
*****

Pogi/Ganda Points: 295
Offline Offline

Gender: Male
Posts: 2151


Enter any 11-digit prime number to continue...


WWW
« Reply #3 on: April 06, 2010, 01:33:25 PM »

Hindi naman ako nawawala Grin
Nagbakasyon lang ng ilang araw.
Logged

bbench
Size C Battery
*****

Pogi/Ganda Points: 13
Offline Offline

Gender: Female
Posts: 141


:) :D :D :D :)


WWW
« Reply #4 on: April 06, 2010, 01:40:31 PM »

hmmm my text file po dpat irun 1st column first name 2nd column last name 3rd column id # 4th column department,,,,, tas pag ni run dapat gagawa ka ng file na lalabas alphabetical order example ung result aa.txt for last name ending with a..... ang prob ko po dapat di lalabas ung mga files na walang names sa listahan like x ganun eh lumalabas padin kahit gamitan ng wc -l sa script.....like this (43 Apr  6 14:00 emp-hh.txt
 0 Apr  6 14:00 emp-ii.txt
42 Apr  6 14:00 emp-jj.txt)

dpat la si emp-ii.txt .......
Logged

bench!
zer0w1ng
Technical People
Gas Turbine
*****

Pogi/Ganda Points: 295
Offline Offline

Gender: Male
Posts: 2151


Enter any 11-digit prime number to continue...


WWW
« Reply #5 on: April 07, 2010, 06:45:25 AM »

... alphabetical order example ung result aa.txt for last name ending with a.....

Ending or STARTING with 'a'?

Anyway, here is the script which ignores the 0 lines file in the list:
wc -l * | awk '{ if ($1!=0) print $0 }'

This uses awk and is very common tool in Unix scripting.
Logged

anthonydp
Size D Battery
******

Pogi/Ganda Points: 47
Offline Offline

Gender: Male
Posts: 296



WWW
« Reply #6 on: April 07, 2010, 10:45:34 AM »

here's how to find the last letter of a string, save this file as "lastchar" file

Code:
#!/bin/bash
echo "input string = "$1
echo "length of string = "${#1}
echo $1 | cut --characters=${#1}

Quote
-bash-3.2$ chmod +x ./lastchar
-bash-3.2$ ./lastchar elephant
input string = elephant
length of string = 8
t
-bash-3.2$ ./lastchar "elephant mouse"
input string = elephant mouse
length of string = 14
e
-bash-3.2$

it's the code "${#1}" that returns the length of the input string in variable $1.
Logged

your question appears to be an XY Problem.

why don't you just tell us exactly what you're trying to do?
anthonydp
Size D Battery
******

Pogi/Ganda Points: 47
Offline Offline

Gender: Male
Posts: 296



WWW
« Reply #7 on: April 07, 2010, 10:52:50 AM »

puede rin pala:

echo "hello" | wc -m
6

"man wc"  for more info.
Logged

your question appears to be an XY Problem.

why don't you just tell us exactly what you're trying to do?
The Philippine Electronics and Technology Forum
   

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Activex control in Vbasic for capturing video and image...badly needed
BASIC, Visual BASIC and VB.NET
burnikz 0 532 Last post May 15, 2008, 11:30:49 PM
by burnikz
Buying >>>>>all ECE books and review books.badly needed.
ECE Students
100407 8 885 Last post May 15, 2011, 10:45:29 AM
by bonjee
BADLY NEEDED A TOPIC for THESIS! :(
General Electronics and Technology Discussion
navyblue015 5 784 Last post March 07, 2010, 09:10:49 AM
by mentamide
help....badly needed...ADC0804
Computer Interfacing and Digital Communications
coi12 3 152 Last post January 18, 2011, 06:22:46 AM
by toasted siopao
chasis A10A AA philips service manual badly needed! « 1 2 »
Philips Televisions
jmg 24 376 Last post February 11, 2011, 06:07:41 PM
by Papaden
pa-help poh...badly needed lang talaga.. asap
Communications Engineering
yes_secreto 5 389 Last post February 10, 2011, 12:49:16 PM
by Cross Talk
bakit kaya andaming needed badly na post dito?
Chit Chat
1SaGing5 7 108 Last post January 28, 2012, 03:07:18 PM
by jacks
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!