LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-08-2006, 03:04 AM   #1
oudoubah
LQ Newbie
 
Registered: Oct 2005
Location: France
Distribution: Arch
Posts: 23

Rep: Reputation: 0
Question [awk]how to remember groups in sub


Hello!

I've a config file like this :
Code:
[disks]
/dev/sda1 1 1275 83
/dev/sda2 1276 1406 82
/dev/sda3 1407 19929 8e
[swap]
...
My script have to read this file and use fdisk to recreate my partitions.

Here is my code with awk :
Code:
awk '/\[disks\]/ {
   getline ;
   while ($0 !~ /^\[.*/) {
      if ($0 != "" ) {
         device=$0;
         gsub(/(\/dev\/[^0-9]*)([0-9]+).*/, "device=\1=\2=", device) ;
         print device;
      }
      getline
}}' save.conf
Here is my result:
Code:
device===
device===
device===
I would like to separate the number of the partition and the device.
In my test, i would like to have:
device=/dev/sda=1
device=/dev/sda=2
device=/dev/sda=3

Is anyone could help me to understand my mistake?

Many thanks!
 
Old 08-08-2006, 09:17 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
If you're not just having to do some exercise, sfdisk can dump the partition table to a file which can then be restored.
For example:

Save the partition table...
sfdisk -d /dev/hda > hda.out

Resore the partition table
sfdisk /dev/hda < hda.out
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
groups (system default groups) Xavius Linux - General 2 07-18-2012 02:50 AM
Map Windows NT Groups to UNIX Groups - why? kenji1903 Linux - Networking 4 10-16-2007 11:52 AM
limit to nesting groups within groups? geekgrl Linux - General 3 10-16-2007 11:50 AM
winbind: wbinfo -g only lists global groups from PDC and not local groups saradiya Linux - Networking 0 12-01-2003 02:58 AM
Groups members of other groups bentz Linux - Security 6 06-22-2003 11:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration