1754919 Members
3045 Online
108827 Solutions
New Discussion юеВ

script

 
Hari Prasad S.R
Occasional Contributor

script

Hi,

Below is my file-system output I want to know how find and replace from /osxfiles to /osx using sed editor.

Filesystem 1k-blocks Used Available Used% Mounted on
/dev/disk9 3121344 1314624 1806720 42% /osxfiles
17 REPLIES 17
Rasheed Tamton
Honored Contributor

Re: script

Hi,

I do not know whether I got your question correctly. But from the first look, I think you want as below:

bdf| sed 's/osxfiles/osx/'
Hari Prasad S.R
Occasional Contributor

Re: script

i want to kknow how exactly we can define /osxfiles [/ needs to be included],
as i have one more like

/sap1/sap to /usr/sap

but i have some of the file systems like /sap1/opt , /sap1/usr.

if i use that other file-systems will also get effected.


regards,
Hari
Sandman!
Honored Contributor

Re: script

Not sure I understand but it would help if you could clarify by giving an example.

~thanks
Rasheed Tamton
Honored Contributor

Re: script

Just give example:

Like
present status:
osxfile
sap

I need as:
osx
usr/sap, etc.

Unless you let us know exactly what you want; it will delay you get a correct solution.

Regards.
Tor-Arne Nostdal
Trusted Contributor

Re: script

Hard to see what you're actually up to. This is why the answers is vague. A more direct question could give more accurate answer.

Here's some general comments, but if you're not confident with what you're doing you should be careful.
-------

You have a mountpoint named /osxfiles

You should not try to change the name of this directory as long as the filesystem is mounted.

Create a new directory named osx
Make sure there is no process using the /osxfiles filesystem.
Unmount the filesystem currently mounted on /osxfiles. Then mount it on the new mountpoint(directory) named osx.

mkdir /osx
umount /osxfiles
cp -p /etc/fstab /etc/fstab.old
cat /etc/fstab | sed 's/osxfiles/osx/g' > /etc/fstab.new
# Inspect the /etc/fstab.new
more /etc/fstab.new
# If file is ok, make it the active one
cat /etc/fstab.new > /etc/fstab
mount /osx

Find files with string 'osxfiles':
find / -type f -print | grep -l '/osxfiles'
NB! This will search through ALL files in your system and report the filename on files containg string '/osxfiles'

To change with sed the string osxfiles into osx in a file you do it like this:
cat myfile | sed 's/osxfiles/osx/g' | > /tmp/myfile.tmp
cat /tmp/myfile.tmp > myfile

Search and replace can also be done in 'vi' similarily as with sed.
example:
vi myfile
:s/osxfiles/osx/g
:wq

/Tor-Arne
I'm trying to become President of the state I'm in...
spex
Honored Contributor

Re: script

Hello,

For each mountpoint you wish to migrate, first create a directory to contain the filesystem, then modify the appropriate entries in /etc/fstab. Then 'umount ', and 'mount -a' to mount all filesystems. Alternatively, if you wish to manually mount the filesystems, make sure you mount parent filesytems before their children (e.g. /var before /var/tmp).

PCS
Hari Prasad S.R
Occasional Contributor

Re: script

Hi,

Below is the output of the dbf i just wanted fire backup from this server excluding /,/stand and /tmp. I wanted to do this only with sed editor bcoz same script i will
put in some 150 servers and the problem is if i give bdf command it will show many
file-systems and backup should happen for all the file-systems excluding / /stand and /tmp.

$ bdf
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 2097152 1494496 598520 71% /
/dev/vg00/lvol1 295024 73200 192320 28% /stand
/dev/vg00/lvol8 2826240 1918640 901648 68% /var
/dev/vg00/lvol7 1056768 1003352 53144 95% /usr
/dev/vg00/lvol4 77824 34904 42920 45% /tmp
/dev/vg01/lvol1 18530304 16975068 1530996 92% /oracle
/dev/vg00/lvol6 8245248 5311432 2910928 65% /opt
/dev/vg00/lvol5 20480 10432 10024 51% /home

so can any one tell me how to exclude these file-systems.

currently i have arrived only till. like below

$ bdf | awk '{print $6}'
Mounted
/
/stand
/var
/usr
/tmp
/oracle
/opt
/home
Rasheed Tamton
Honored Contributor

Re: script

Hi,

That means you want to exclude /stand and /tmp from the bdf output - possibly I assume that you are trying a fbackup with a graph file.

bdf|sed 1d| awk '{print $6}'|grep -Ev 'stand|tmp'

Rasheed Tamton
Honored Contributor

Re: script

Hi Hari,

If you want to use only awk; then:


bdf|sed 1d| awk ' $6 !~ /(stand|tmp)/ {print $6}'

Rgds,
Rasheed Tamton.