Posts Tagged ‘Unix Shell Script’

Some Useful Unix File Finding Commands

Some Useful Unix File Finding Commands
Following are some bunch of commands that might be useful if you want to find files in unix/linux. Large Files Find files larger than 10MB in the current directory downwards... find . -size +10000000c -ls Find files larger than 100MB... find . -size +100000000c -ls Old Files Find files last modified over 30days ago... find . -type f -mtime 30 -ls Find files last ... Full story

Unix Shell Script Line Ending & Executable Issue with Subversion

Unix Shell Script Line Ending & Executable Issue with Subversion
Unix File Line Ending always gives you problem if you have your development environment in Windows and servers in Unix. Also if you are using Subversion as source control system then you need to be very careful about line endings. I had this issue where a shell script was deployed on Unix machine. But I was not able to run the shell script. It gave error: $> ... Full story

Replace Text in Variables & Single/Multiple-Files in UNIX

Replace Text in Variables & Single/Multiple-Files in UNIX
Shell Script is fun. I love it when I know which commands to use. There are almost thousands of Here is a simple trick to Replace Text and Variables in Files in UNIX. We will use command sed - it is very useful to find and replace text in single or multiple files. Replace Text in Single ... Full story

Shell Script to Rename & Move files in Unix

Problem Statement: I have few files in source directory. I have to move them to another destination directory. The source directory have *.txt files that needs to be moved to destination directory. The destination filename should be *.txt.backup. So how to accomplish the above task in Unix Shell Script? Well the solution is simple: cd source/ for file in *.txt do mv "${file}" ../destination/"${file}.backup" Run a loop for each ... Full story

Generate Random Number in UNIX Shell Script

Generate Random Number in UNIX Shell Script
RANDOM is a peculiar shell variable, but useful nonetheless. Peculiar because its value changes each time it is referenced (yes, this is by design). As you may have already guessed, RANDOM is a random number generator. The number generated is an integer between 0 and 32767, and can come in handy when writing shell scripts. ... Full story

Writing Functions in Shell Script

Writing Functions in Shell Script
Have you ever written a huge Unix script and thought you would have divided this script into pieces of reusable code? Well don't worry. You can create functions in unix shell script and make reusable code and call the function from your unix code. Hello World Function in Unix shell script First let us see a simple ... Full story
Copyright © 2010 ViralPatel.net. All rights reserved.