d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Help With Script In Linux
Prev12
Add Reply New Topic New Poll
Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
Mar 22 2014 03:18pm
Quote (eric838 @ 21 Mar 2014 21:45)



btw trying to do a    do...while  loop like c language but idk how

in C++  that would be :


Code
do
{
    cout << "Choose between those 2 options:" <<endl;
    cout << "1. Display file acces of a file" << endl;
    cout << "2. Display content of a file" << endl;
    cin >> choice;
}
while (choice != 1 && choice != 2 );



n wat about dat?
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Mar 22 2014 03:41pm
Quote (eric838 @ Mar 22 2014 04:18pm)
n wat about dat?


Something like

Code
choice = 0
until [$choice -eq 1 -o $choice -eq 2]; do
echo "Choose between these 2 options:"
echo "1. Display file access of a file"
echo "2. Display content of a file"
read choice
done

Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
Mar 24 2014 03:20pm
still need help I have to display current path ($PWD) in Upper case and like that : / -> HOME -> USER -> BIN


HAve the following code not complete (need Uppercase) and not working:

Code
chain1=$PWD
chain2="/"
nbchars= `expr length $chain1`
cnt=1
carac=""
while [$cnt -lt $nbchars+1]; do
carac=${chaine1:$cnt:1}
if ["$carac"="/"]; then
carac=" -> "
fi
chain2 = ${chain2}${carac}
let cnt=$cnt+1
done
echo "$chain2"


Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
Mar 24 2014 06:39pm
anyone?
Member
Posts: 16,450
Joined: Mar 25 2012
Gold: 158.71
Mar 24 2014 07:59pm
Code
abduct@insomnia:~# echo "testing" | tr '[:lower:]' '[:upper:]'
TESTING
abduct@insomnia:~# echo "testing" | awk '{ print toupper($0) }'
TESTING
abduct@insomnia:~#


from the mighty duck.

This post was edited by dolarsignzeroxeighty on Mar 24 2014 08:00pm
Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
Mar 24 2014 08:13pm
Quote (dolarsignzeroxeighty @ 24 Mar 2014 20:59)
Code
abduct@insomnia:~# echo "testing" | tr '[:lower:]' '[:upper:]'
TESTING
abduct@insomnia:~# echo "testing" | awk '{ print toupper($0) }'
TESTING
abduct@insomnia:~#


from the mighty duck.


ty but I need like this too : / -> HOME -> USER -> BIN
Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
Mar 25 2014 06:41am
Quote (eric838 @ 24 Mar 2014 21:13)
ty but I need like this too :  / -> HOME -> USER -> BIN


anyone?
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Mar 25 2014 07:35am
Are you capable of doing anything yourself? You can't take the hints given to you and form a completed answer from them? You want us to do it all?. You realize I know very little about bash scripting? Every answer I gave you I simply googled the key terms you used in each reply. Are you incapable of doing that?

If you are then I refuse to help you anymore. I would rather you fail, flunk, and drop this major. I don't want any more shitty programmer's in the workforce.
Member
Posts: 16,450
Joined: Mar 25 2012
Gold: 158.71
Mar 25 2014 04:32pm
Code
abduct@insomnia:~/Desktop/shellcode# pwd | awk '{ n=split($0,pwd_array,"/"); for(i=2;i<=n;i++) { if(i==n) { printf "%s", toupper(pwd_array[i]) } else { printf "%s->", toupper(pwd_array[i]) } } }'
ABDUCT->DESKTOP->SHELLCODE
abduct@insomnia:~/Desktop/shellcode#


If your awk version allows it, there is a join() method that will take an array and concat it with a spacer for you instead of looping through the array yourself. You should really just be googling this shit... it is comon sense if you have any brains at all.


from the mighty duck.
Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
Mar 25 2014 07:42pm
Quote (dolarsignzeroxeighty @ 25 Mar 2014 17:32)
Code
abduct@insomnia:~/Desktop/shellcode# pwd | awk '{ n=split($0,pwd_array,"/"); for(i=2;i<=n;i++) { if(i==n) { printf "%s", toupper(pwd_array[i]) } else { printf "%s->", toupper(pwd_array[i]) } } }'
ABDUCT->DESKTOP->SHELLCODE
abduct@insomnia:~/Desktop/shellcode#


If your awk version allows it, there is a join() method that will take an array and concat it with a spacer for you instead of looping through the array yourself. You should really just be googling this shit... it is comon sense if you have any brains at all.


from the mighty duck.


ty its all ok now
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll