bash

How to copy files and add prefix at the same time?

I am not familiar with osx terminal command. I have a java project containing many package. Some classes have same name in different package. I need to copy all of the class files into a directory, so I need to add corresponding package prefix on each files. For example, I have root/com/example1/test.java and root/com/example2/test.java two classes having the same name…
Read more

How to cut a space from a string in a Unix shell script

I am reading a file and cutting a column based on some logic. My issue is I am not able to cut a column with space. This is the code for testing – st=”1|alalhabad|up|tushar|kesarwani|90| mls k|19990|india|420|24|m” HardErrorCheckColumnValue=`echo $st | cut -d’|’ -f7` echo $HardErrorCheckColumnValue The output should be – mls k But I am getting- mls k How do I…
Read more

Recursively filename change, number shifting

I am writing as I have found in here many solutions to recursively change the filenames in Linux, but not exactly the one that matches my case. I have a bunch of files in one directory called: FileName_01.pdf ….. FileName_20.pdf and I want to recursively change their names so that: FileName_01.pdf -> FileName_15.pdf FileName_02.pdf -> FileName_16.pdf …. FileName_20.pdf -> FileName_35.pdf…
Read more

Bash: count lines that occur together

I’ve been working on a script that will take in a css file as a txt file. The end result would be that the script would count the number of properties that occur more than once, which i have achieved, and to count the occurences of properties which appear as part of a group, e.g. 2 font-size:10px; + font-family:Helvetica; 3…
Read more

How to send facebook message from linux console (command-line)

Old days many admins uses sms-gates for sending important informations from their systems e.g. “Power down, UPS is working now!”, “Power Up, UPS is off!” or “CPU Temp too high!”. Today in Facebook era we use messenger instead of SMS, so I wonder if I could create a command-line bash or php script for such thing. The idea – cron…
Read more