- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: shell script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2012 11:58 PM
08-07-2012 11:58 PM
shell scrpt help
$pwd
$/home/rajesh
$cd data1
$pwd
$/home/rajesh/data1
$ls
fa00 fa02 fa03 fa04 fa05 fa06 fa07 fa08 fa09 fa10 fa11 fa12 fa13 fa15 fa16
fa17 fa18 nas file2 fa18 fa19 fa20 fa21 fa22 fa23 fa24 fa25 fa26 fa27 fa28 fa29
fa 30 fa31 fa32 fa33 fa34 fa35 fa36
$
we need to write one script for mv command.
we need to move all file files and folser under the /home/rajesh/data1 , except nas and file2 folders
how to write the script.
please help me
- Tags:
- mv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2012 12:44 AM - edited 08-08-2012 03:35 PM
08-08-2012 12:44 AM - edited 08-08-2012 03:35 PM
Re: shell script help
Where are you moving it to? The same filesystem?
If the same, then move all files and then move nas and file2 back. If doing a copy, this would be too expensive.
In a real shell you can also do:
mv !(nas|file2) target/
First, try an echo to make sure it does what you want.
- Tags:
- pattern
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2012 02:18 AM
08-08-2012 02:18 AM
Re: shell script help
hi dennis,
thnaks for providing the details.
but now user request to delete the all files expect nas&file2.
pls help me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2012 06:55 AM - edited 08-08-2012 06:56 AM
08-08-2012 06:55 AM - edited 08-08-2012 06:56 AM
Re: shell script help
Something like this should work:
# cat mv-files.sh
#!/usr/bin/sh
cd /home/rajesh/data1
DATAFILES=$(ls -1 |grep -v -e nas -e file2)
mv ${DATAFILES} /new/dir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2012 10:19 AM
08-08-2012 10:19 AM
Re: shell script help
>now user request to delete the all files except nas & file2.
Just replace "mv" by "rm -rf". Check it with echo first.