help in modification of code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help in modification of code
# 1  
Old 08-28-2012
help in modification of code

I have below code, i want to run this code, but this below code should run on


Code:
myblocka
myblockb
myblockcc
myblockxx
myblockanything

but it will not run on "myblock"

Code:
for BLOCK in /sys/block/myblock*
do
        echo "100000" > "$BLOCK"/abcd

done


Note: This below code block line should not run on myblock while run as above.

Code:
for BLOCK in /dev/myblock*

do
       echo "123"> "$BLOCK"

done


Last edited by zaxxon; 08-28-2012 at 04:33 AM.. Reason: placed description outside of code tags
# 2  
Old 08-28-2012
Hi

Code:
for BLOCK in /sys/block/myblock[a-z]*

Guru
# 3  
Old 08-28-2012
Quote:
Originally Posted by guruprasadpr
Hi

Code:
for BLOCK in /sys/block/myblock[a-z]*

Guru
Hi Guru,

Try if directory name contains special character or number in it...
This script won't work here...

Code:
myblock_new
myblock9

# 4  
Old 08-28-2012
Quote:
Originally Posted by guruprasadpr
Hi

Code:
for BLOCK in /sys/block/myblock[a-z]*

Guru
Will above code run on below? Only characters are there no special characters and no numbers are there.

/sys/block/myblockaa
/sys/block/myblockbb
/sys/block/myblockdc
/sys/block/myblockabcd

Same if i use for another code, is below line correct?

Code:
 for BLOCK in /dev/myblock[a-z]


Last edited by learnbash; 08-28-2012 at 04:43 AM..
# 5  
Old 08-28-2012
Quote:
Originally Posted by learnbash
Will above code run on below? Only characters are there no special characters and no numbers are there.

/sys/block/myblockaa
/sys/block/myblockbb
/sys/block/myblockdc
/sys/block/myblockabcd

Same if i use for another code, is below line correct?

Code:
 for BLOCK in /dev/myblock[a-z]

Why don't you try it out for yourself with something like:
Code:
for BLOCK in /sys/block/myblock[a-z]*
do
  echo "$BLOCK"
done

This User Gave Thanks to Franklin52 For This Post:
# 6  
Old 08-28-2012
Or something like

Code:
for BLOCK in $(ls /sys/block/myblock* | grep -v '^/sys/block/myblock $')



# 7  
Old 08-28-2012
Quote:
Originally Posted by Franklin52
Why don't you try it out for yourself with something like:
Code:
for BLOCK in /sys/block/myblock[a-z]*
do
  echo "$BLOCK"
done

sorry sir, actually i forgot to check this. Now i check this
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

cp modification

I'm usia Raspbian, a Debian subset, and wondering what work would be involved in altering the cp command. cp at present needs a full path and file name for source and at least full filename for destination. How can I change this so the second parameter isn't needed? So if the destination... (6 Replies)
Discussion started by: MuntyScrunt
6 Replies

2. Shell Programming and Scripting

Modification in script

Hi, I have below script, i want to monitor that that ntp server listed in setting is under sync or not. I wrote below script but it is not working properly. Here are problems, first it should server under sync if "*" shows and rest if shows "+" it means it is next server in waiting list.... (4 Replies)
Discussion started by: learnbash
4 Replies

3. Shell Programming and Scripting

Awk modification

I need help modifying the code below. DATAFILE is a log file. I have two strings i need to search for in the log file. The two strings are: 1. ERROR 2. com.rolander.promotions.client awk 'BEGIN { while((getline < "'${SFILE}'")>0) S FS="\n"; RS="\n" } (11 Replies)
Discussion started by: SkySmart
11 Replies

4. Shell Programming and Scripting

Help for File Modification

Hi, I have a file abcd.txt. cat abcd.txt output is as follows : "aa"~"bb"~"001"~""~""~"cc" "dd"~"005"~"" ~""~"kk"~"aa"~"00 8"~""~""~ I want the output looking like: cat abcd.txt "aa"~"bb"~"001"~""~""~ "cc""dd"~"005"~""~""~ "kk"~"aa"~"008"~""~""~ I have a script. (4 Replies)
Discussion started by: mnmonu
4 Replies

5. Shell Programming and Scripting

Help with file modification

Hi, I have a file test.txt . The contain of the file is as below : 365798~SAPUS~PR5~0000799005~ADM CHARG MEDCAL INS~~~~~~~~~~~~~~~~~~~~~~~~SLAC480 I want to modify this file. And file contain loking like "365798"~"SAPUS"~"PR5"~"0000799005"~"ADM CHARG MEDCAL... (6 Replies)
Discussion started by: mnmonu
6 Replies

6. UNIX for Dummies Questions & Answers

Modification of Two Files

I have a script that produces two output files each containing the same number of lines <file1.txt> and <file2.txt>. What I need to do is combine both files into a new file <file3.txt> where line 1 of <file1.txt> is put to the right (and on the same line) as line 1 of <file2.txt> and then the same... (5 Replies)
Discussion started by: theref
5 Replies

7. Shell Programming and Scripting

Need a modification on this script

Hi All I have files contains rows which look like this: 2 20090721_16:58:47.173 JSUD2 JD1M1 20 IAM 966591835270 249918113182 b 3610 ACM b 3614 ACM b 3713 CPG b 3717 CPG f 5799 REL b 5815 RLC b 5817 RLC :COMMA: NCI=00,FCI=6101,CPC=0A,TMR=00,OFI=00,USI: :COMMB: BCI=1234: :RELCAUSE:10: ... (1 Reply)
Discussion started by: zanetti321
1 Replies

8. IP Networking

ifconfig modification

Hi all,,i have problem with my homework form my lecture.. He is give me a homework to create: ifconfig eth0 0.255.255.255 1.1.168.192 my lecture says, i can making the shell scripting to finish my homework.. i have question, can setting ifconfig like in the upper? (1 Reply)
Discussion started by: demhyt
1 Replies

9. Shell Programming and Scripting

File modification

Dear all, i have a file which contains this lines. 0-0 CC=1 0-01 0-011 0-0111 0-01110 F=500 CC=1 L=15 M=5 TRD=3948... (2 Replies)
Discussion started by: panknil
2 Replies

10. UNIX for Advanced & Expert Users

Swap modification

How can i modify (expand) the swap memory (Sco Enterprise 5.0.5) using the swap command...? The excisting swap is 512 and i want to increase it to 1024...? Thanx in advance (2 Replies)
Discussion started by: psychofredy
2 Replies
Login or Register to Ask a Question